Logical Operators in Code Your Own Adventure 2!


#1

Hi, I am getting the following error message;
//SyntaxError: Unexpected identifier.I've looked at this for ever! I'd appreciate any advice.Thanks
//My code is as follows
var user = prompt("Do you like french fries DEEP FRIED, MALT AND VINEGAR of MAYO AND KETCHUP?").toUpperCase();
DEEP FRIED=true;
MALT VINEGAR=true;

switch(user) {
case 'DEEP FRIED':

    console.log("I like them nice and greasy!");

        if(DEEP FRIED && MALT VINEGAR) {
         console.log("Slap yo momma good!");

} else {
console.log("No way!");
break;
}

//end of 1st case
case 'MALT VINEGAR'
console.log("Tangy and tart!");

    if(Tangy and tart || !(greasy) {
        console.log("Makes your lips pucker!");
    } else {
        console.log("My arteries are clogging just thinking of this!");
    break;

//end of second case
}
case 'MAYO AND KETCHUP':
console.log("These are the best!");
break;

    default:
     console.log("They're all too fattening!");

}


#2
} else {
console.log("No way!");
break;
}

You included break; inside the else code

case 'MALT VINEGAR'

You forgot a ':'

   if(Tangy and tart || !(greasy) {
You forgot a parenthesis after (greasy)

else {
        console.log("My arteries are clogging just thinking of this!");
    break;
//end of second case
}

Again you included break inside the else code

Hope it helps :smiley:


#3

Hi again,
I did everything that you said ( thank-you for your help). The new message I got was
//SyntaxError: missing before statement.Noting else was changed.I looked at on the web to see
if I could resolve myself before coming back.It said something regarding not being able to recognize contraction signs ( you're) and that it ends the code. So I changed it to say "they are"
but that didn't work so I put it back to the original way.
var user = prompt("Do you like french fries DEEP FRIED, MALT AND VINEGAR OR MAYO AND KETCHUP?").toUpperCase();
var DEEP FRIED=true;
var MALT VINEGAR=true;

switch(user) {
case 'DEEP FRIED':

    console.log("I like them nice and greasy!");



    if(DEEP FRIED && MALT VINEGAR) {
        console.log("Slap yo momma good!");
    } else {
        console.log("No way!");
    }    
        break;
   //end of 1st case    
case 'MALT VINEGAR':
    console.log("Tangy and tart!");


    if(Tangy and tart || !(greasy)) {
        console.log("Makes your lips pucker!");
    } else {
        console.log("My ateries are clogging just thinking of this!");
    }

    break;    
     //end of second case   
case 'MAYO AND KETCHUP':
     console.log("These are the best!");
     break;

     default:
     console.log("They're all too fattening!");

}