10. Overview


#1


Hi guys! I've just been introduced to the and/&&, or/||, not/!. There's not really an assignement here, but I don't really understand part of it.

var iLoveJavaScript = true;
var iLoveLearning = true;

if(iLoveJavaScript && iLoveLearning) {
  // if iLoveJavaScript AND iLoveLearning:
  console.log("Awesome! Let's keep learning!");
} else if(!(iLoveJavaScript || iLoveLearning)) {
  // if NOT iLoveJavaScript OR iLoveLearning:
  console.log("Let's see if we can change your mind.");
} else {
  console.log("You only like one but not the other? We'll work on it.");
}

Focussing on this part:
else if(!(iLoveJavaScript || iLoveLearning)) {
// if NOT iLoveJavaScript OR iLoveLearning:

Wouldn't this mean ONE of them isn't true? Since it is not iLoveJavaScript OR iLoveLearning. But then, in the else statement it says they only like one of them, so I'd say with this statement they mean that both of them aren't true. Why doesn't say this instead:
else if(!(iLoveJavaScript && iLoveLearning))

I'd say, then they mean it's both not iLoveJavaScript and not iLoveLearning. Can someone explain this to me?


Edit: nevermind, I've gone through the rest, understand it now.


#2

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