Stuck on logical operators


#1


var user = prompt("how are you?").toLowerCase();
switch(user) {
    case "good" :
        var time = prompt("Do you have time?").toLowerCase();
        var alcohol = prompt("Do you like alcohol?").toLowerCase();
          if( time === "yes" && alcohol = "no") {
              console.log("ok, very good") 
          } else {
    console.log("nice");
          }
 break;
    case "not bad":
        var you = prompt("Are you ok?").toLowerCase();
        var tommorow = prompt("are you working tommorow").toLowerCase();
        if (you === "yes" || tommorow === "no") {
    console.log("ok") 
        } else { 
            console.log("nice") 
        }
break;
    case "great":
    console.log("cool");
break;
   default:
  console.log("very nice");
}
  
anyone know why this code does not work?


#2

this line:

if( time === "yes" && alcohol = "no")

you use a single equal sing, which means assign, while you want to compare


#3

For alcohol = "no" in your if condition, you should use the === comparison operator. What error message are you getting?


#4

Doesn't mean you have to remove your answer, now OP can choice from multiply answers, which offers multiply perspectives (which is better then a single one)


#5

Ive tried doing it and I still get an error, 'ReferenceError: Invalid left-hand side in assignment'


#6

I have used 2 equal signs instead of 1 or 3 for alcohol and it worked, thanks


#7