Skip to content

Instantly share code, notes, and snippets.

@fernandocanizo
Last active May 8, 2018 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandocanizo/518319c982a79ea277305d4d66afbd21 to your computer and use it in GitHub Desktop.
Save fernandocanizo/518319c982a79ea277305d4d66afbd21 to your computer and use it in GitHub Desktop.
fantasy animal generator
'use strict';
const randomItem = (itemsArray) => itemsArray[Math.floor(Math.random() * itemsArray.length)];
const makeFantasyAnimal = () => {
const animales = ['perro', 'gato', 'jirafa'];
const verbos = ['escupe', 'caga', 'estornuda'];
const elementos = ['fuego', 'hielo', 'moco'];
return `${randomItem(animales)} ${randomItem(verbos)} ${randomItem(elementos)}`;
};
function * buildAnimalArmy() {
while (Math.random() > .1) {
yield makeFantasyAnimal();
}
}
for (const fantasyAnimal of buildAnimalArmy()) {
console.log(fantasyAnimal);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment