Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda