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

171
Visualizações
How to filter an array of arrays and just return part of each inner array?

I have the following array of arrays:

const myArray = [ ['1', 'first'], ['2', 'second'], ['3', 'third'], ['4', 'fourth'] ]

I want to return an array like:

[ 'first', 'second', 'third', 'fourth' ]

I'm trying the following filter:

const res = myArray.filter( elm => elm[1] )

but it doesn't return the desired filter, just return the same...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

.filter() is used to create a subset of an array containing elements that pass a certain requirements test.

.map() is used create a new array consisting of the results of passing the elements through a function.

The following should work as you intend:

const res = myArray.map(elm => elm[1]);
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