random-letters
Version:
Tiny module to generate random letters with specific length.
21 lines (16 loc) • 423 B
JavaScript
/*
* random-letters
* https://github.com/eddsuarez/random-letters
*
*/
;
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
function randomLetters(length) {
let random;
let output = '';
for (let i = 1; i <= length; i++) {
output += letters.substring(random = Math.floor(Math.random() * letters.length), random + 1);
}
return output;
};
module.exports = randomLetters;