Switch in 4/6


#1

I created the switch and codecademy says it is ok. But every answer i pick in the prompt says the default whats the problem?

This is my code:

var user = prompt("Do you Want to fight me?").toUpperCase();

switch(user) {
case 'Yes':
console.log("Thats the spirit go for it! Is attacking");
break;
case 'No':
console.log("You such a pussy! Runs away");
break;
case 'Maby':
console.log("Thats not a choice FIGHT or either RUN AWAY");
break;
default:
console.log("Whatever....");
}


#2

This is because you call .toUpperCase on the prompt. This changes the response to all uppercase, if you were to put "Yes" in the prompt, it would become "YES", which doesn't match any case(s). The way the cases should go are:

case 'YES': 
//Code Here
break;
case 'NO': 
//Code Here
break;
case 'MABY': 
//Code Here
break; 
default:
//Code Here
break;

#3

Thank you very mutch, now it works :smiley:


#4


Help Please :smile: