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

152
Vistas
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
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