Lesson 5 I got a syntaxerror I do not understand


#1

Hello all,
I tried to write a switch statement but I got a syntax error that said: expected expression, got keyword 'case'.

I do not understand this error because in a switch statement there should be "case" keywords.
What did I do wrong?

Here is my programme:

var user = prompt("Do you want to play another game?").toUpperCase();
switch(user){
case 'YES':
var userAge = prompt("How old are you?").toUpperCase();
if(userAge > 14){
console.log("All right. Let's play game1!");
} else {
console.log("All right. Let's play game2!");
break;
case 'NO':
var secondAnswer = prompt("Are you sure?").toUpperCase();
if (user === NO){
user === true;
} else { user === false:
if (secondAnswer === YES){
secondAnswer === true;
} else { secondAnswer === false;
}
if(user&&secondAnswer) {
console.log("OK, no big deal.");
} else {
console.log("Just one game?");
break;
case 'SOME OTHER TIME':
if(userAge < 14){
console.log("Maybe one of your parents?");
} else {
console.log("We wil wait for you.");
}
break;
default:
console.log("Hope to see you again.");
}


#2

You are missing to close the brackets when you are using else:

Add } before break for all cases.

But you have more problems. I don't understand what are you doing here:

Remember that with === you are comparing, not assigning value.


#3

Thank you for your suggetions.
I will try to repair it.


#4

Not sure if this is the issue, but you wrote:
var userAge = prompt("How old are you?").toUpperCase();

If the expected answer is a number (in a string), why is there a conversion .toUpperCase()? That's not necessary.