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

119
Vistas
Should I use map/reduce/flatten functions to manipulate Multi-Dimensional Array in Javascript

I have this data :

[
["A","X1","Y1"],
["A","X2","Y2"],
["A","X3","Y3"],
["B","X4","Y4"],
["B","X5","Y5"],
["B","X6","Y6"],
]

and would like to change the array structure to be this :

[
["A",["X1","Y1"],["X2","Y2"],["X3","Y3"]],
["B",["X4","Y4"],["X5","Y5"],["X6","Y6"]],
]

I have been playing around with flatten function (flatten with a 'key' (i.e A and B) and then join all back together at the end.) - but the 'key' change from A to B (and potentially to C, D, E ....) has got me stumped.

I would appreciate any pointers as to the most efficient direction to go. Has any one else met this type of need ? Is there a better way (outside nested interations)

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