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

108
Views
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
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!