Created
June 14, 2018 17:06
-
-
Save Bamblehorse/80bb3e061ccb21f0e816972549fafdfa to your computer and use it in GitHub Desktop.
Insult and Compliment giver
This file contains 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 getRandomInt(max) { // From MDN | |
return Math.floor(Math.random() * Math.floor(max)); | |
} | |
const length = array => array.length | |
const verbs = ['smell', 'fart', 'look', 'move', 'eat', 'walk', 'talk', 'sleep', 'smile'] | |
const presentSimpleVerbs = ['worries', 'sings', 'cooks', 'fidgets', 'wriggles', 'dances', 'runs', 'sets stuff on fire'] | |
const nouns = ['house', 'dog', 'poop', 'worm', 'lawyer', 'little girl', 'piece of cheese', 'french poodle'] | |
const timeRelatedAdverbs = ['always', 'never', 'sometimes', 'often', 'rarely', 'occasionally'] | |
const getRandomItem = array => { | |
let length = array.length | |
return () => array[getRandomInt(length)] | |
} | |
const randomVerb = getRandomItem(verbs) | |
const randomPresentSimpleVerb = getRandomItem(presentSimpleVerbs) | |
const randomNoun = getRandomItem(nouns) | |
const randomTimeRelatedAdverb = getRandomItem(timeRelatedAdverbs) | |
function insult() { | |
let verb = randomVerb() | |
let noun = randomNoun() | |
let presentSimpleVerb = randomPresentSimpleVerb() | |
let timeRelatedAdverb = randomTimeRelatedAdverb() | |
return `You ${verb} like a ${noun} that ${timeRelatedAdverb} ${presentSimpleVerb}!` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment