Get Random Letter From Alphabet with JavaScript
function generateAlphabet(capital = false) {
return [...Array(26)].map((_, i) => String.fromCharCode(i + (capital ? 65 : 97)));
}
function getRandomLetter() {
const alphabet = generateAlphabet();
return alphabet[Math.floor(Math.random() * alphabet.length)];
}
getRandomLetter();
no comments