My code passes through the lesson but it only returns the default, can you please tell me why?


#1

<var user = prompt("You have to defeat your enemy. You only get one prop. Do you choose a rock, knife or gun").toUpperCase();

switch(user) {

case 'rock':
var lose = prompt("How courageous! Are you strong (YES or NO)?").toUpperCase();
var smart = prompt("Are you smart?").toUpperCase();
if(lose === 'YES' || smart === 'YES') {
console.log("You will need both of these to help you with only that rock");
} else {
console.log("You're not strong OR smart? Well, if you were smarter, you probably wouldn't have picked the rock!");
}
break;

case 'knife':
var experience = prompt("Are you experienced (YES or NO)?").toUpperCase();
var brains = prompt("Are you smart?").toUpperCase();
if(experience === 'YES' || brains === 'YES') {
  console.log("You will need both of these to help you with only that knife");
} else {
  console.log("You're not experienced OR smart? Well, if you were smarter, you probably wouldn't have picked the knife!");
}
break;

case 'gun':
var win = prompt("Good choice! Are you fast (YES or NO)?").toUpperCase();
var license = prompt("Do you have your license?").toUpperCase();
if(win === 'YES' && license === 'YES') {
console.log("You will surely defeat your enemy with a gun");
} else {
console.log("You will still probably win with the gun");
}
break;
default:
console.log("I didn't understand your choice. Hit Run and try again, this time picking rock, knife, or gun!");
}


#2

Hi this line

var user = prompt("You have to defeat your enemy. You only get one prop. Do you choose a rock, knife or gun").toUpperCase();

remove the .toUpperCase(); becasue you case arent't uppercase

case 'rock':
 ...

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.