Created
January 19, 2018 17:48
-
-
Save bronzehedwick/15fb0495d0b1f5d5ccd8301a0cb8307c to your computer and use it in GitHub Desktop.
A dumb script that pops out an even dumber name...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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