10/14


#1

// Complete lines 3 and 4!

var iLoveJavaScript = "hai";
var iLoveLearning = "hello";

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


#2

The Instruction was:

Starting to make sense?
Set both variables in the editor to true and hit Save & Submit Code to see what happens!

I hope you are aware
that by setting the variable to a string Value instead of a Boolean Value
you have given them a truthy-condition

= https://developer.mozilla.org/en-US/docs/Glossary/Truthy
= https://developer.mozilla.org/en-US/docs/Glossary/Falsy


#3

This will work as wel :wink:

var iLoveJavaScript = prompt("I love Java Script");
var iLoveLearning = prompt("I love learning");

switch(iLoveJavaScript && iLoveLearning){
case 'yes':
iLoveJavaScript = true;
iLoveLearning = true;
break;
default:
iLoveJavaScript = false;
iLoveLearning = false;

}

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


#4

I have a questions about the else if statement in this lesson. I understand that the construction is using the logic nor, that is, it is neither a nor b. But I thought that would be synonymous with writing !(a and b), that is, it is not a and not b. Though, when I replace the || in the else if line with &&, if you have one variable false and one variable true, you trigger that else if condition, and if you have both false it triggers it still triggers that else if condition. How come?


#5

@voyenavion,

++++++++ logical AND OR !AND !OR
+++++ truth table
I created the so-called truth-table's

=======================
  AND  | true  | false
 ------|-------|-------
 true  | true  | false
 ------|-------|-------
 false | false | false
 ------|-------|-------

=======================
 !(AND)| true  | false
 ------|-------|-------
 true  | false | true
 ------|-------|-------
 false | true  | true
 ------|-------|-------

=======================

..

  OR   | true  | false
 ------|-------|-------
 true  | true  | true
 ------|-------|-------
 false | true  | false
 ------|-------|-------

=======================
 !(OR) | true  | false
 ------|-------|-------
 true  | false | false
 ------|-------|-------
 false | false | true
 ------|-------|-------

#6

could you explain how these are read?


#7

@voyenavion,

=======================
       | opt-2 | opt-2  
       |  is   |  is  
  AND  | true  | false
 ------|-------|-------
 opt-1 | Result| Result <if opt-1 is true AND opt-2 is true -> Result is true
  is   |  is   |  is  
 true  | true  | false
 ------|-------|-------
 false | false | false
 ------|-------|-------

#8

Why isn't this working? Thanks.

// Complete lines 3 and 4!

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


#9

Do not put a space between true and the semi-colon


#10

what is the error? And @harvardpride this does not matter.