Skip to content

Instantly share code, notes, and snippets.

@mindplace
Created March 23, 2016 14:58
Show Gist options
  • Select an option

  • Save mindplace/5e3466098c0ce47e1a36 to your computer and use it in GitHub Desktop.

Select an option

Save mindplace/5e3466098c0ce47e1a36 to your computer and use it in GitHub Desktop.
function inconsistentAdder(numOne, numTwo) {
console.log("Let's play a game! Me, the program, will flip a coin.");
console.log("If it's heads, I'll add up your numbers,");
console.log("and if it's tails, I'll throw them back in your face.");
console.log("Flipping a coin...");
var add = function add(numOne, numTwo) { return numOne + numTwo};
var coin = ["heads", "tails"][Math.floor(Math.random())];
if (coin === "heads") {
console.log("\nHeads. Fine, here's your sum...")
console.log(add(numOne, numTwo))
}
else {
console.log("\nTails! Take your stupid numbers back!")
console.log([numOne, numTwo])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment