Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
Using Map to Display Two Arrays Overlapping Each Other

Consider two arrays:

props = ['prop1','prop2','prop3']

about = ['about1','about2','about3']

I'm looking to display them in a way where the index of each array is paired to the other, sort of like:

props[0] - 'prop1'
about[0] - 'about1'

props[1] - 'prop2'
about[1] - 'about2'

So far i've tried nesting two maps together but i'm getting an output of many repetitive or invalid values. Does anyone know how I can tweak the solution I have to properly display the arrays with map?

 props.map( arg => {
   return (
    about.map ( arg2 => {
      <div>
      <p> {arg} </p>
      <p> {arg2} </p>
      </div>
    })
   );
  })
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

What you need to do is use the index property on the map method to access the element in the second array at the same index as the first.

Your code would look like this

 props.map((arg, i) => {
   return (
     <div>
       <p>{arg}</p>
       <p>{about[i]}</p>
     </div>
   );
 });

However, you should note that for this to work, both arrays have to be of the same length, or the one you're mapping should be of greater length than the second. Else you would get undefined for some values.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda