5. Logical Operators - What am I doing wrong?


So, the game is not finished, but still something is wrong. 'invalid assignment left-hand side'.
Ignore the words of the game, it hasn't got much sense.


ReferenceError: invalid assignment left-hand side

var answer = prompt("Where to? Hospital, school, beach?").toLowerCase();


{case 'hospital':
    var sick = prompt("Are you sick","yes or no").toLowerCase();
    var like = prompt("Do you like hospitals?","yes or no").toLowerCase();
        if (sick='yes'||like='yes'){console.log("Get well soon!")}
        else if (sick='yes'&&like='yes'){console.log("Crazy sky.")}
    else{console.log("Walk around then.")}

case 'school':
    console.log ("School drool.");
case "beach":
    console.log ("Is it summer?");
    console.log ("Boom.")}


a single equal sign means assign, if you want to compare (which i would do in a if condition) use two or 3 equal signs


The two statements above are the ones which have an "invalid assignment left-hand side". Seeing the mod's response, can you figure out why?


check it here


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