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

161
Views
How to manipulate a 2 levels array of objects and transform it in another structure in Javascript?

I have the following array of objects that comes from a MySql query:

[
  {col1:1, col2:a},
  {col1:1, col2:b},
  {col1:1, col2:c},
  {col1:2, col2:d},
  {col1:2, col2:e},
  {col1:2, col2:f},
  {col1:3, col2:g},
  {col1:3, col2:h}
]

I would like to transform into the following object:

[
  {col1:1, col2:[a,b,c]},
  {col1:2, col2:[d,e,f]},
  {col1:3, col2:[e,g,h]}
]

Is there a way to perform this task using map or array filter?

about 4 years ago · Juan Pablo Isaza
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!