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

115
Vistas
javascript: rearrange array of objects with arrays, injecting objects into groups along with their parameters

Dataset:

Lastnotes,Status,PeriodStart,PeriodEnd,Client
worked on assignment and completed,Completed,1/1/2022,1/31/2022,JohnSmith
worked on assignment and finished it,Completed,1/1/2022,1/31/2022,JaneDoe
stalled,InProg,2/1/2022,2/28/2022,JohnSmith

I presently have an array of objects with each objects formed as follows:

var TheObject = {
  group: element.Client,
  data: [{
    label: element["LastNotes"],
    data: [{
      timeRange: [element["PeriodStart"], element["PeriodStart"]],
      val: element.Status
    }, ]
  }, ],
};

In the end, I get:

var TheObject = {group: "JaneDoe: [{label: "worked on assignment and finished it",data: [{timeRange: ["1/1/2022","1/31/2022"],val: "Completed"},]},],};

...and then two more for the other two items.

Is there some way I can group by Client so that the two JohnSmith entries become:

var TheObject = {group: "JohnSmith: [{label: "worked on assignment and finished it",data: [{timeRange: ["1/1/2022","1/31/2022"],val: "Completed"},]},{label: "stalled",data: [{timeRange: ["2/1/2022","2/28/2022"],val: "InProg"},]}],};
about 4 years ago · Santiago Gelvez
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