Skip to content

Instantly share code, notes, and snippets.

@lzehrung
Last active May 17, 2023 04:37
Show Gist options
  • Select an option

  • Save lzehrung/d0092c99c37a733e338544083eb3f811 to your computer and use it in GitHub Desktop.

Select an option

Save lzehrung/d0092c99c37a733e338544083eb3f811 to your computer and use it in GitHub Desktop.
const alpha = 'abcdef'.toUpperCase().split('');
const randomNumber = () => Math.floor(Math.random() * 10).toString();
const randomLetter = () => alpha[Math.floor(Math.random() * alpha.length)];
const randomCharacter = () => Math.random() > 0.5 ? randomLetter() : randomNumber();
function generateOtp(length = 6) {
return Array.from({ length }, randomCharacter).join('');
}
const pass = generateOtp();
console.log('%c' + pass, `background: #${pass}; color: black`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment