Logical operators


#1


Anyone help me ?


https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Unexpected token &&


var user=prompt("What you want to do?").toUpperCase();
switch (user)
{
    case 'yes':
        if(&&) {
            
        }
        else{
            
        };
        break;
    case 'no':
        if(||){
            
        }
        else{
            
        };
        break;
    case 'may be':
        if(&&){
            
        }
        else{
            
        };
        break;
    ;
    default:
        if(||){
            
        }
        else{
            
        };
    break;
}


#2

You need two statements that return a boolean when you use logical operators.
eg.

if (2 === 2 && 1 === 1) {
    //do something if both statements are true
};

Can't have just && as your if statement.


#3

ohh, got it. thankks bro :slight_smile:


#4

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