Switch Problem


#1

Please help with my code! I already checked that there is an upper case alignment, semicolons etc. but it keeps telling me "SyntaxError: Unexpected token ILLEGAL". Thank you!

var user = prompt ("Will you go left, right, or straight?").toUpperCase();

switch (user) {
case 'LEFT':
console.log("Left is never right...");
break;
case 'RIGHT':
console.log("I think you're right!");
break;
case 'STRAIGHT":
console.log("Straight is only for scaredy-cats.");
break;
default:
console.log("There's no way you can go there!");
}


#2

@annamcp,
A string should either be encapsulated in
a pair of single-quotes-' '
or
a pair of double-quotes-" "

So change your case-clause

'STRAIGHT":

in you switch statement.


#3

aaah how could I have missed that. Thanks so much!


#4

@annamcp,

But keep in mind.....
SyntaxError: Unexpected token ILLEGAL".
the token being
the case-clause......