single comparison in an if statement often is not enough to determine whether data matches your criteria. For example, you may need to check to see if a user enters a number with a certain range. To accomplish this task, you will need the logical operators in your if statement.
&& (AND)
(3 + 2 = 5) && (6 + 2 = 8) TRUE
(4 + 3 = 9) && (3 + 3 = 6) FALSE
|| (OR)
(3 + 6 = 2) || (4 + 1 = 5) TRUE
(1 + 1 = 3) || (3 + 3 = 9) FALSE
! (NOT)
!(4 + 3 = 5) TRUE
These logical operators which result in a true/false condition are also referred to as Boolean Operators.
Operator Precedence
You can mix logical operators in statements as long as you understand the order in which the logical operators will be applied (precedence).
1. The NOT operator (!) is applied first,
2. then, the AND operator (&&),
3. and finally the OR operator (||).