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

154
Views
Push a one-dimensional array into a 2-dimensional array

How do I push a 1-dimensional array into a 2-dimensional array?

When I use either:

phData.push(ehRow);
phData.push([ehRow]);

all I get is the last ehRow replicated 1000 times after exiting the for loop. If I hard code the 26 elements of ehRow as arguments to the push, I get what I want, but surely there's a better way.

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

0

As a guess:

var array = ['a','b','c']
var array_2d = array.map(x => [x])

console.log(array_2d); // --> [['a'],['b'],['c']]

var another_2d_array = [['d'], ['e'], ['f']]
var final_2d_array = [...another_2d_array, ...array_2d]

console.log(final_2d_array); // --> [['d'],['e'],['f'],['a'],['b'],['c']]

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!