Created
February 16, 2022 18:29
-
-
Save appoll/6acbb4cf62bd5cf7cd7c650db90a0fb9 to your computer and use it in GitHub Desktop.
03-logical.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uncomment the code between /* and */; | |
// Run the code; | |
// See what happens; | |
// Does it make sense? | |
// AND operator: && | |
// 3.1 | |
userName = "Siri" | |
if (3 > 1 && userName === "Siri"){ | |
console.log("3.1 Yes!"); | |
} else { | |
console.log("3.1 No!"); | |
} | |
console.log("\n\n"); | |
// 3.2 | |
/* | |
userName = "siri" | |
if (3 > 1 && userName === "Siri"){ | |
console.log("3.2 Yes!"); | |
} else { | |
console.log("3.2 No!"); | |
} | |
console.log("\n\n"); | |
*/ | |
// 3.3 | |
/* | |
age = 18 | |
if (age > 18 && true){ | |
console.log("3.3 Yes!"); | |
} else { | |
console.log("3.3 No!"); | |
} | |
console.log("\n\n"); | |
*/ | |
// 3.4 | |
/* | |
age = 18 | |
if (age < 19 && age > 17) { | |
console.log("3.4 Yes!"); | |
} else { | |
console.log("3.4 No!"); | |
} | |
console.log("\n\n"); | |
*/ | |
// OR operator: || | |
// 3.5 | |
/* | |
age = 18; | |
userName = "Albert"; | |
if (age < 16 || userName === "Albert"){ | |
console.log("3.5 Yes!"); | |
} else { | |
console.log("3.5 No!"); | |
} | |
console.log("\n\n"); | |
*/ | |
// 3.6 | |
/* | |
newsletterSubscribed = false; | |
age = 45; | |
if (newsletterSubscribed || age > 40){ | |
console.log("3.6 Yes!"); | |
} else { | |
console.log("3.6 No!"); | |
} | |
console.log("\n\n"); | |
*/ | |
// 3.7 | |
/* | |
letter1 = "a"; | |
letter2 = "b"; | |
if ("c" > letter1 || "b" < letter2){ | |
console.log("3.7 Yes!"); | |
} else { | |
console.log("3.7 No!"); | |
} | |
console.log("\n\n"); | |
*/ | |
// 3.8 | |
/* | |
name1 = "Paul"; | |
name2 = "Andreas"; | |
if (name1 > name2 || false){ | |
console.log("3.8 Yes!"); | |
} else { | |
console.log("3.8 No!"); | |
} | |
console.log("\n\n"); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment