Code Your Own Adventure 2! Logical operators


#1


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


ReferenceError: Invalid left-hand side in assignment


ar user = prompt("Who are you?").toLowerCase();

switch(user){
    case'cat':
        var weight = prompt("Are you fat?").toLowerCase();
        if(user="cat" && weight="yes"){
            console.log("You are a fat cat");
            }
        else{
            console.log("You are a cat and you are not fat");
            }
        
        break;
    case'dog':
        var weight = prompt("Are you fat?").toLowerCase();
        if(user = "dog" || weight = "no"){
            console.log("You are a good dog!");
            }
        else{
            console.log('That\'s OK!')
            }
        break;
    case'human':
                if(user){}
        else{}
        break;
    default:
        console.log("Hello!");


#2

Hi in all your if condition

if (condition) {
    #do something
}
else {
    #do something
}

you should change the = with === you wan to compare and not to set(a new value) then you didn't close the switch statement

switch(user) {
    #here put your if and else statement
}

#3

Thanks! I'll change it now


#4

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