December 21, 201312 yr No matter what I pick (yes or no), I'm getting the default return.... -------------------------------------- var user = prompt("You look like you're in shape, I may let you pass to my kingdom. Are you brave, yes or no?").toLowerCase(); switch(user) { case user == "yes": var strong = prompt("Are you strong?"); var smart = prompt("Are you smart?"); if(strong === yes && smart === yes){ console.log("You may pass!"); } else { ("You cannot pass, it is much to dangerous for you in there!"); } break; case user == "no": var swift = prompt("You coward! You may not pass! Are you swift enough to escape my sword!"); var strong2 = prompt("Are you strong enough to take a hit/ get past the barrier to escape me?"); if(swift === yes || strong2 === yes) { console.log("The knight charges for you, you duck and run away"); } else{ console.log("The knight slices you in half, you lay dead on the kingdom bridge"); } break; case user == "maybe": var friendly = prompt("You seem confused, have my sword, IF, you feel you have the power to wield it?"); if (prompt === yes){ console.log("Take it, it is of no use to me against most of the people who pass through here!"); console.log("A troll passes by and you slice him in half, well done!"); } else{ console.log("Be gone then."); } break; default: console.log("You weren't even brave enough to put yes or no, shame on you!"); }
December 22, 201312 yr You're using case incorrectly. switch (user) { case "yes": ... case "no": ... case "maybe": ... default: ... }