Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Forked from jaxatax/randomWord.js
Created October 2, 2019 00:08
Show Gist options
  • Save topherPedersen/bd1e485b4ae69c46edcd86fda505a196 to your computer and use it in GitHub Desktop.
Save topherPedersen/bd1e485b4ae69c46edcd86fda505a196 to your computer and use it in GitHub Desktop.
Random word generation in JS.
Array.prototype.randomElement = function () {
return this[Math.floor(Math.random() * this.length)];
}
var consonant = [
"th",
"th",
"n",
"mb",
"r",
"f",
"n",
"w",
"v",
"nt",
"r",
"f",
"nd",
"s",
"c",
"b",
"z",
"v",
"m",
"br",
"l",
"rg",
"st",
"p",
"gl",
"mc",
"pl",
"gh",
"th",
"n",
"mb",
"r",
"f",
"nds",
"nn",
"nc",
"d",
"nn",
"ll",
"c",
"nt",
"n",
"d",
"t",
"gr",
"w",
"v",
"r"
];
var vowel = [
"a",
"e",
"u",
"i",
"o"
];
for (var i = 0; i < 10; i++) {
var word = consonant.randomElement() + vowel.randomElement() + consonant.randomElement() + vowel.randomElement() + consonant.randomElement();
console.log(word);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment