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

121
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
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