Skip to content

Instantly share code, notes, and snippets.

@ourmaninamsterdam
Created August 8, 2015 14:26
Show Gist options
  • Save ourmaninamsterdam/122d97d549e609e458fa to your computer and use it in GitHub Desktop.
Save ourmaninamsterdam/122d97d549e609e458fa to your computer and use it in GitHub Desktop.
createRandomString()
function createRandomString(minLen, maxLen) {
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''),
stringLen = Math.floor(Math.random() * (maxLen - minLen + 1)) + minLen,
string = '';
for(var i = 0; i < stringLen; i++) {
string += alphabet[Math.floor(Math.random() * alphabet.length)];
}
return string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment