Created
January 15, 2020 09:53
-
-
Save megadix/12969a57f47483ecede7fd47b9840a0c to your computer and use it in GitHub Desktop.
Javascript random alphanumeric
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function randomAlpha(n) { | |
| let result = ''; | |
| for (let i = 0; i < n; i++) { | |
| const rint = Math.floor(Math.random() * Math.floor(15)) + 10; | |
| const c = rint.toString(26); | |
| result += c; | |
| } | |
| return result; | |
| } | |
| console.log(randomAlpha(1)); | |
| console.log(randomAlpha(3)); | |
| console.log(randomAlpha(10)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment