Unexpected token case


#1

This is driving me nuts...I've spent a couple hours on it trying to figure it out....

HELP.

Here is my code

var user = prompt("What is a good beer?").toUpperCase();
switch(user)
{
case "Stouts":
{console.log("Good but not my favorite.");}
var beerChoice = prompt("Do you like Belching Beaver or Stone?")
if(Stone === "Yes" || Beaver === "Yes")
{console.log("Me too");}

else
{console.log("You should, they're good");}
break;
case "Porters":
{console.log("Sometimes.");}
var oldVelocity = prompts("Ever had the old Velocity?")
if( yes && no)
{console.log("It's really good.");}
else
{console.log("You should, they're good.");}
break;}
case "IPAs":
{console.log("Now, you're talking.");}
break;
default:
prompt("Not even close.")
}


#2

@digitalninja71950,

1

You use a closing-curly-bracket-} in the wrong place,
closing the switch statement
like

switch(user) {
case "Stouts":
{console.log("Good but not my favorite.");}
var beerChoice = prompt("Do you like Belching Beaver or Stone?")
if(Stone === "Yes" || Beaver === "Yes") 
{console.log("Me too");}

else
{console.log("You should, they're good");}
break; 
case "Porters":
{console.log("Sometimes.");}
var oldVelocity = prompts("Ever had the old Velocity?")
if( yes && no) 
{console.log("It's really good.");}
else
{console.log("You should, they're good.");} 
break;}

and therewith a following case is NOT expected by the Javascript-Interpreter

2

Have a close look at

prompts()

3

A pair of curly-brackets-{ }
are used to encapsulate a so-called code-block
encapsulating a set of statements which should stand together
like

if (condition) {
     //IF code-block
}

or

while ( condition) {
    //WHILE code-block
}

Don't use it
like
{ console.log("x"); }
or
return {""};

Please read the Javascript code-convention
http://javascript.crockford.com/code.html <== Javascript code-convention