Skip to content

Instantly share code, notes, and snippets.

@shcyiza
Created July 21, 2020 18:23
Show Gist options
  • Save shcyiza/9606a63f162db3cd59b43abb14407981 to your computer and use it in GitHub Desktop.
Save shcyiza/9606a63f162db3cd59b43abb14407981 to your computer and use it in GitHub Desktop.
generate random digit string
function generateDigitToken(length) {
let result = "",
characters = "0123456789",
charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(
Math.floor(Math.random() * charactersLength),
);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment