Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
¿Cómo filtrar una matriz de matrices y simplemente devolver parte de cada matriz interna?

Tengo la siguiente matriz de matrices:

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

Quiero devolver una matriz como:

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

Estoy probando el siguiente filtro:

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

pero no devuelve el filtro deseado, solo devuelve lo mismo...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.filter() se usa para crear un subconjunto de una matriz que contiene elementos que pasan una determinada prueba de requisitos.

.map() se usa para crear una nueva matriz que consta de los resultados de pasar los elementos a través de una función.

Lo siguiente debería funcionar como usted pretende:

 const res = myArray.map(elm => elm[1]);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!