Get Random Letter From Alphabet with JavaScript

node v14.20.1
version: 2.0.0
endpointsharetweet
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();
Loading…

no comments

    sign in to comment