Skip to content

Instantly share code, notes, and snippets.

@bingdian
Last active July 31, 2016 09:31
Show Gist options
  • Save bingdian/e17fa1fb65e9b7342a260c11b98c5666 to your computer and use it in GitHub Desktop.
Save bingdian/e17fa1fb65e9b7342a260c11b98c5666 to your computer and use it in GitHub Desktop.
Generator random string
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generatorRandomString() {
return Math.random().toString(36).substr(2,6);
}
function generatorEmailSuffix() {
var domains = ['.com', '.net', '.org', '.cc', '.edu', '.cn'],
len = domains.length;
return domains[getRandomInt(0, len)];
}
function generatorEmail() {
return generatorRandomString() + '@' + generatorRandomString() + generatorEmailSuffix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment