-
-
Save tkh44/4417143 to your computer and use it in GitHub Desktop.
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 randomString(length) { | |
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''); | |
if (! length) { | |
length = Math.floor(Math.random() * chars.length); | |
} | |
var str = ''; | |
for (var i = 0; i < length; i++) { | |
str += chars[Math.floor(Math.random() * chars.length)]; | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment