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

122
Visualizações
How to generate unique user ID like Zerodha's user ID with Node.js/JavaScript

I'm trying to generate random unique User ID for one of my project and found Zerodha has very easy to remember user ids.

In Zerodha user ID: First two char's are Alphabets and then four char's are numbers.

How to make Id's Like Zerodha: "AC1940","AZ9940", "YM1300" etc.. ?

I wanted them to be unique and easy to remember.

Thank you.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You could generate random alphabets and number from ASCII code and Math.random() function and join them in a string.

const generateCharacter = (base, range) => String.fromCharCode(base + Math.floor(Math.random() * range)),
      userId = Array.from({length: 2}, () => generateCharacter(65, 26)).join('') +
               Array.from({length: 4}, () => generateCharacter(48, 10)).join('');
console.log(userId);

about 4 years ago · Juan Pablo Isaza Relatório

0

By respect of guys methods, those are not standard ways for unique random id. one of the standard and best ways to get random and standard methods for that is UUID.

EDITED:

you can use this uuid nodejs package to install and get the uuid unique random id corrctly.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can create a random 6 digit number as

var randomNumber = (min, max) =>
  Math.floor(Math.random() * (max - min + 1)) + min;

function generateUUID() {
  const alphabets = [0, 1];
  return Array.from({ length: 6 }, (_, i) => {
    return alphabets.includes(i)
      ? String.fromCharCode(randomNumber(65, 90))
      : randomNumber(0, 9);
  }).join("");
}

console.log( generateUUID() );

about 4 years ago · Juan Pablo Isaza Relatório
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