Created
November 10, 2020 12:22
-
-
Save rproenca/283e3d9061574d882d20fd7b1004da05 to your computer and use it in GitHub Desktop.
Generate a random string (letters and numbers) of a given length
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
const getRandomString = length => { | |
let s = ''; | |
do { | |
s += Math.random() | |
.toString(36) | |
.substring(2); | |
} while (s.length < length); | |
s = s.substr(0, length); | |
return s; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment