Skip to content

Instantly share code, notes, and snippets.

@olifante
Last active May 12, 2017 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save olifante/b33096d85b9177e34cff876faf6ec2f7 to your computer and use it in GitHub Desktop.
Save olifante/b33096d85b9177e34cff876faf6ec2f7 to your computer and use it in GitHub Desktop.
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