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

134
Vistas
Non-repeating random combined arrays

I need to combine 2 different string arrays to create a name, both with 50 elements. I'll call both arrays A and B. So, the name is A[x] + B[y], X and Y being rng between 1 and 50. But these rng's cant return the same value for the next 9 objects. The object goes like this(acting sort of like a json/api):

const A = {50 different names}
const B = {50 different surnames}

const Data = [{
  firstName: A[Math.floor(Math.random() * (50-1) + 1)],
  secondName: B[Math.floor(Math.random() * (50-1) + 1)],
},
{
  firstName: A[Math.floor(Math.random() * (50-1) + 1)],
  secondName: B[Math.floor(Math.random() * (50-1) + 1)],
}, ...]

It returns the name on a card, and each new object creates a new card.

<h1>{firstName} {secondName}</h1>

As it is now, I get random names, but occasionaly they repeat. Is there any way to fix 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