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

158
Views
How to rearrange array with this format in JS?

I have an array of objects of key-values in this format and I need to transform it. In each period, I have two (or more) statuses (empty or full, although there could be more). Each of these statuses has a certain number of observations (count).

//original format 
const test = [
  {
    "count":[8,31,3],
    "period":["2021-12","2022-01","2022-01"],
    "status":["empty","empty","full"]
  }
]

//transformation I need
output = [
  {
    period:"2021-12",
    status:"empty",
    count:8
  },
  {
    period:"2022-01",
    status:"empty",
    count:31
  },
  {
    period:"2022-01",
    status:"full",
    count:3
  }
]

How to rearrange the format of this array in JS? I have tried using a reduce function but haven't been able to wrap my head around it.

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