var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var result = ""
var chaactersLength = characters.length;
for ( var i = 0; i < 5 ; i++ ) {
result += characters.charAt(Math.floor(Math.random() * chaactersLength));
}
console.log(result)
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
}
const array = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
const string = "abcdefghijklmnopqrstuvwxyz";
// random item from Array
console.log(array[Math.floor(Math.random() * array.length)]);
// random Char from String
console.log(string[Math.floor(Math.random() * string.length)]);
strRandom({
includeUpperCase: true,
includeNumbers: true,
length: 5,
startsWithLowerCase: true
});