generate random email javascript 1

generate random email javascript

var chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
var string = '';
for(var ii=0; ii<15; ii++){
    string += chars[Math.floor(Math.random() * chars.length)];
}
alert(string + '@gmail.com');
// Generates a random "Gmail"

Here is what the above code is Doing:
1. We create a variable called chars and assign it a string of all the characters we want to be included in our random string.
2. We create a variable called string and assign it an empty string.
3. We create a for loop that will run 15 times.
4. Inside the for loop, we add a random character from the chars string to our string variable.
5. We alert the string variable, which now contains a random 15 character string.

Similar Posts