Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda