Code Your Own Adventure 2! (switch) 4/6


#1

When I submit this code, the code runs through all the other cases, even if I properly typed in the case word, and goes straight to the default console.log. What is the issue? Thank you.

var user = prompt("What weapon do you choose?").toUpperCase();

switch(user) {

case 'gun':
var afraid = prompt("Are you afraid to kill(YES or NO)?").toUpperCase();
var brave = prompt("Are you brave?").toUpperCase();
if(afraid === 'NO' && brave === 'YES') {
console.log("You can't be afraid to use a gun!");
} else {
console.log("You need to be brave to use a gun!");
} break;

case 'knife':
var tickle = prompt("Are you willing to tickle someone to death with it(YES or NO)?").toUpperCase();
var nose = prompt("Are you willing to pick their nose with it?").toUpperCase();
if(tickle === 'YES' && nose === 'NO') {
console.log("You better be!");
}
else {
console.log("You have to pick their nose with it!");
} break;

case 'cheese':
var wack = prompt("Are you going to wack cheese at the enemy(YES or NO)?").toUpperCase();
var slip = prompt("Are you going to make the enemy slip off the floor?").toUpperCase();
if (wack === 'YES' && slip === 'NO') {
console.log("You'll need more than cheese to defeat the enemy"); }
else {
console.log("You might slow down the enemy, but not defeat him/her");
} break;

default:
console.log("You need a better weapon!");

}


#2

Hi to do it simple just remove the .toUpperCase() here

var user = prompt("What weapon do you choose?").toUpperCase();

#3

Voila! Code worked! Thank you wizmarco.