javascript get random character from string code example
Example 1: javascript generate random string
Math.random().toString(36).substring(2);
Example 2: random alphabet javascript
Math.random().toString(36).substr(2, 5);
Example 3: javascript random char
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
function generateRandomCode(){
let result = ""
let charactersLength = characters.length;
for ( var i = 0; i < 6 ; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result
}