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

100
Views
Elegant way to REDUCE a 2D array into 1D

Given the following 2D array: var arr = [[1,2,3],[4,5,6],[7,8,9]]

How can get [1,4,7] without using for loops?

My simplest solution is transposing and returning only the first (0th) row. There must be a more elegant solution, Perhaps something that I can chain onto an array to make it a one-liner?

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

0

Try doing

var arr = [[1,2,3],[4,5,6],[7,8,9]];
var newaArr = arr.map(el => el[0]);
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!