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

170
Views
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 answers
Answer question

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 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!