Last active
December 24, 2015 06:29
-
-
Save varjmes/6757870 to your computer and use it in GitHub Desktop.
Playing with Switch & Case Statements.
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 user = prompt("An elderly lady approaches you, brandishing a sharpened umbrella. Do you FIGHT, do you RUN or do you CURL up into the fetal position?").toUpperCase(); | |
switch(user) { | |
case 'FIGHT': | |
console.log("You'd really hurt an old lady? For shame."); | |
var hits = prompt("How many times will you hit her?"); | |
var sure = prompt("Are you sure?").toUpperCase(); | |
if (hits >= 1 && sure === 'YES') { | |
console.log("How Heinous. She's dead. And you're a bad person."); | |
} else if (hits === 0 || sure === 'NO' ) { | |
console.log("Admirable. I'm glad you changed your mind."); | |
} else { | |
console.log("She attacked you first. You're dead."); | |
} | |
break; | |
case 'RUN': | |
console.log("You yella-bellied foo!"); | |
break; | |
case 'CURL': | |
console.log("She pokes you with her umbrella repeatedly until death envelopes you."); | |
break; | |
default: "You seemed to have typed an incorrect command, doofus. Try again."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment