Logical Operators Help Please


#1

My error says:

'Syntax error: missing ) after condition'

I don't see where I need to place another )

Any help is much appreciated

var user = prompt("You have three wishes.").toUpperCase();

switch(user) {
    case 'fly' :
        if(fly && flying) {
            console.log("You can fly");
        } else {
            console.log("Keep trying");
        }
        console.log("You can fly anywhere your heart desires");
        break;
    case 'mind read' :
        if(mind reader || read minds) {
            console.log("You are a mind reader");
        } else {
            console.log("Keep trying");
        } 
        console.log("You can read people's minds");
        break;
    case 'pizza' :
        console.log("You can turn any Republican into a pizza with no cheese");
        break;
    default:
        console.log("Choose either fly, mind read, or pizza");
}


#2

First of all, you still need to add a break in your default case. On top of that, if( mind reader || read minds) doesn't mean anything. Those are not variables, they're not strings. Even if they were stings, they wouldn't be checking if they were equal to anything.


#3

opphh, brain fart. You're right! I completely forgot to set variables for my conditions. Thank you so much for your help!


#4

:joy: I think I snort/chortled loud enough to disturb my cube neighbor


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.