Where do I need them?
if (age < 18) {
console.log("Go home!");
}
if (age < 18) {
console.log("Go home!");
} else {
console.log("Welcome!");
}
if (age < 18) {
console.log("Go home!");
} else if (age < 24) {
console.log("Welcome to the first floor!");
} else {
console.log("Welcome to the second floor!");
}
| == | equal to |
| === | equal value and equal type |
| != | not equal |
| !== | not equal value or not equal type |
| > | greater than |
| < | less than |
| >= | greater than or equal to |
| <= | less than or equal to |
Where do we need them?
var isAnAdult = (age >= 18);
var isReady = true;
var hasPaid = false;
| && | AND |
| || | OR |
| ! | NOT |
If the customer is an employee or a child without celiac, who's age is between 3 and 5, we will serve meatballs.
if ( isAnEmployee || (!hasCeliac && age >= 3 && age <= 5) ) {
console.log("We will serve you meatballs!");
}
Lets see...