5. Logical Operators


Hello folks! Could anybody help me with this?
I can't figure out why the "Or" operator inside the "if" statement on case "running' is not working. Id doesn't matter what the input in "var time" is, it prints out "I'm up for it".

Really appreciate it. Thanks!

var answer = prompt("what would you fancy doing today?").toLowerCase();

var user = answer ;

switch(user) {
case 'running':
console.log("It's a lovely day for a run!");
var time = prompt("What time would like to go for a run?").toLowerCase();
if (time === "morning time" || "in the afternoon") {
console.log("I'm up for it!");
} else {
console.log("I'm busy this time");
case 'drinking':
var confirm = prompt("Are you serious?").toLowerCase();
if ('drinking' && confirm === "yes") {
console.log("Here we go again!");
} else {
console.log("Tell me something new!");
case 'sleeping':
console.log("you're so lazy!");
console.log("Right... Enjoy your day! I've got something to do.");


I've lost count of how many times this has come up. It is a common misconsception that the variable and comparison will carry through to the second operand in the expression. However, sadly, this is not the case.

The expression in the first operand is not carried to the second. They are independent. That means if the first operand yields false, we need to evaluate the variable and its comparator in the context of the second operand. This means it has to be there.

if ( A === B || A === C) {}

Notice that A === is in both operands?


Clear as water now! It absolutely makes sense. Sorry, I didn't pay close attention. Neither took enough time to search through the topics. But learned two lessons here!

Thanks for taking the time and explain that again!