4.switch, i keep getting the default anwser


#1

Ok, so no matter what answer i put in such as yes.. no i keep getting the default response, what have i done wrong?

var answer = prompt ("A wild pikachu appears, do you want to battle? Yes / No").toLowerCase();

switch(answer){
case 'Yes':
console.log ("Congrats! You have caught a pikachu!")
break;

case 'No':
console.log ("The pikachu used thunderbolt and now you're dead!")
break;

case 'Maybe':
console.log("The pikachu eats a potatoe")
break;

default:
console.log ("The pikachu runs away")
break;
}


#2

Your cases have upper case letters but you replaced all upper case letters in the user input


#3

Thanks for the help, that worked!


#4

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