Last active
July 31, 2016 09:31
-
-
Save bingdian/e17fa1fb65e9b7342a260c11b98c5666 to your computer and use it in GitHub Desktop.
Generator random string
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 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