Created
April 25, 2015 12:05
-
-
Save alexcorvi/fa16b325c9b71c20e6dd to your computer and use it in GitHub Desktop.
Javascript: Function to create random string
This file contains 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
var getChars = function (size) { | |
var str = '', | |
i = 0, | |
chars = '0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ'; | |
while (i < size) { | |
str += chars.substr(Math.floor(Math.random() * 62), 1); | |
i++; | |
} | |
return str; | |
} | |
console.log(getChars(8)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment