Created
February 9, 2017 12:48
-
-
Save khushalbokadey/661c762121b570c41cac8cd7aae32e33 to your computer and use it in GitHub Desktop.
Generate random string of 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
function getRandomString(len) { | |
if (!len) { | |
len = 8; | |
} | |
var text = ""; | |
var possible = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < len; i++ ) | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
return text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment