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

230
Views
Map an the values from an array of objects to another array of arrays to match a new data structure

How do I get the requiredObject data structure from the rows and columns variable? I know I need to use some higher-order array methods like map, etc. I just find the right combination enter image description here

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

0

This is what I use currently, I am sure there's a better looking solution

let colArray = columns.columns.map(col => col.name)

let transfromedData = []
rows.forEach(row => {
  let temp = {};
  colArray.forEach((key, i) => {
      temp[key] = row[i];
    })
    transfromedData.push(temp)
})
about 4 years ago · Juan Pablo Isaza Report

0

  const sortedColums = columns.columns.sort((a,b) => a.value - b.value).map(x=>x.name)
  const output = rows.map(x => { const entry = {}; x.map((val, idx) => entry[sortedColums[idx]] = val); return entry})
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!