More on control flow in JS


#1

Hi, I don't understand why, even if I type one of the answers included in the cases, the computer always gives me the answer: "What do you mean?" which is the default. I don't find any mistake here.
Any help would be appreciated. Thanks

var weather = prompt ("What would you do in a rainy day?", "Type your ideas here");

switch(answer) {
case 'play tennis':
console.log("I would do the same");
break;
case 'I would be depressed':
console.log("Really? Call me instead!");
break;
case 'sleep':
console.log("Good idea");
break;
default:
console.log("What do you mean?");
break;
}


More on Control Flow in JS - And
#2

HI you saved the prompt in var weather so you should put weather ..

switch(answer)

instead of answer


#3

thank you @wizmarco , this is clear now