5. Logical Operators - What am I doing wrong?


#1

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.


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


ReferenceError: invalid assignment left-hand side


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

switch(answer)

{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.")}
    break;

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


#2

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


#3

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?


#4

check it here


#5

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