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

188
Vistas
JS - Repeat array items n times on n position?

I have entered the array in the format :

let in = [{name: "Milos", repeat: null},{name: "Milos1", repeat: 2},{name: "Milos2", repeat: null},{name: "Milos3", repeat: 4}, .... ];

What is key here, the key is the repeat property.

What that means,

If any item in the array has repeat property, that item must be repeatable in the array, which means, will be placed in position n, with n repeat times, array what is expected as result is :

let out = [
{name: "Milos", repeat: null},
{name: "Milos1", repeat: 2},
{name: "Milos2", repeat: null},
{name: "Milos1", repeat: 2},
{name: "Milos3", repeat: 4}, ...., 
{name: "Milos1", repeat: 2}, ...  
{name: "Milos3", repeat: 4}, ..., 
{name: "Milos1", repeat: 2}, ... 
{name: "Milos3", repeat: 4}, ...];

Note: Dots means items with repeat property null.

Limitation, I don't want to expand the array is there no more space for that.

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