random letter string javascript code example
Example 1: how to generate random character from an array js
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
console.log(makeid());
Example 2: how to generate random string in javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);