Logical or Boolean Operators part 2
Logical Operators
In the following example, we have connected two Boolean expressions with the AND operator.
For this expression to be true, both conditions must be true.
- The first condition determines whether 4 is greater than 2, which is true.
- The second condition determines whether 10 is less than 15, which is also true.
Based on these results, the whole expression is found to be true.
Conditional (Ternary) Operator
Another JavaScript conditional operator assigns a value to a variable, based on some condition.
Syntax:variable = (condition) ? value1: value2
For example:
If the variable age is a value below 18, the value of the variable isAdult will be "Too young". Otherwise the value of isAdult will be "Old enough".
Logical operators allow you to connect as many expressions as you wish.
Logical NOT returns true, if:
Comments
Post a Comment