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

224
Vistas
Multiple Arrays to Single Flatterned Array

Ive got 3 parent arrays that could sometimes be different lengths which are called Options Each Option has values array which can also be different lengths Example of this would be something like this

[
  {
    name: "Option 1",
    values: ["Blue","Red","Orange"]
  },
  {
    name: "Option 2",
    values: ["Small","Medium","Large"]
  },
  {
    name: "Option 3",
    values: ["Cotton","Satin"]
  }
]

The outcome should generate an array like this

[
  {
    title: "Blue/Small/Cotton",
    price: "10.00"
  },
  {
    title: "Blue/Small/Satin",
    price: "10.00"
  },
  {
    title: "Blue/Small/Cotton",
    price: "10.00"
  },
  {
    title: "Blue/Medium/Satin",
    price: "10.00"
  },
]

And So on. Ive tried mapping through the options but knowing the size of the multiple arrays is what I couldnt figure out

SOLUTION I managed to get a solution

product.options.reduce(
      (a, b) => a.flatMap((x) => b.values.map((y) => [...x, y])),
      [[]]
    );
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