Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda