Evaluates between two conditions/expressions and returns true or false
with && (Logical And) operators, both conditions have to be true in order for the whole expression to be true
with || (Logical Or) operators, any of the condition must be true for entire expression to be true; but if all conditions are false then the entire expression is false
Operator | Description | Example (all return true) |
---|---|---|
Logical AND (&&) | expr1 && expr2 | (3 > 1) && “cat”.length === 3 |
Logical OR (||) | expr1 || expr2 | (4 + 1) < 8 || 53 > (9 * 6) |
Add the following expressions in the jsbin below and evaluate the result; use console.log()
to print the result. Don’t forget to press “run” after adding your code.
true && false
true && 8 > (3 * 3) && "hello"
true && (9 / 3 > 5) || "Yolo!"
false || "Apple" === "apple" || parseInt("12") === 12