Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!