Last active
May 12, 2017 16:55
-
-
Save olifante/b33096d85b9177e34cff876faf6ec2f7 to your computer and use it in GitHub Desktop.
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
var warning = function () { | |
console.log("I didn't understand you, please play again.") | |
} | |
var win = function () { | |
console.log("You win!!!!") | |
} | |
var lose = function () { | |
console.log("You lose :-(") | |
} | |
var fight = function () { | |
var question = 'Are you strong?' | |
var instructions = 'YES or NO?' | |
var answer = prompt(question, instructions) | |
if (answer === 'YES') { | |
win() | |
} else if (answer === 'NO') { | |
lose() | |
} else { | |
warning() | |
} | |
} | |
var run = function () { | |
} | |
var pay = function () { | |
} | |
var play = function () { | |
var question = 'You are walking through the forest when a monster jumps out. "None shall pass!" he says, "Unless, of course, you pay me 100 EUR"' | |
var instructions = "Do you FIGHT, PAY or RUN?" | |
var answer = prompt(question, instructions) | |
if (answer === "FIGHT") { | |
console.log("you fight") | |
fight() | |
} else if (answer === "RUN") { | |
console.log("you run") | |
run() | |
} else if (answer === "PAY") { | |
console.log("you pay") | |
pay() | |
} else { | |
warning() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment