Skip to content

Instantly share code, notes, and snippets.

@bronzehedwick
Created January 19, 2018 17:48
Show Gist options
  • Save bronzehedwick/15fb0495d0b1f5d5ccd8301a0cb8307c to your computer and use it in GitHub Desktop.
Save bronzehedwick/15fb0495d0b1f5d5ccd8301a0cb8307c to your computer and use it in GitHub Desktop.
A dumb script that pops out an even dumber name...
function random(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
let vowels = [ 'a', 'e', 'i', 'o', 'u' ];
let consonents = [ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'z' ];
function randomName() {
const clen = consonents.length - 1;
const vlen = vowels.length - 1;
const syllables = random(1, 3);
let output = '';
for (let i = 0; i < syllables; i++) {
const firstLetter = consonents[random(0, clen)];
const vowel = vowels[random(0, vlen)];
const lastLetter = consonents[random(0, clen)];
output += firstLetter + vowel + lastLetter;
}
return output.charAt(0).toUpperCase() + output.substring(1);
}
console.log(randomName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment