How much cash? 50000 How much credit do you have? 75000 Enough to buy this car!
When execution got to the if
statement, it found that
cash >= 25000 --- true, because 50000 >= 25000
and
credit >= 25000 --- true, because 75000 >= 25000
Since all that is required for OR is one true, the complete logical expression was true.
The or-operator is used in a logical expression to insist that there is at least one true. If both sides are true, the entire expression is true. If just one side is true, the entire expression is true. If both sides are false, the entire expression is false. the or-operator is a logical operator because it combines two true/false values into a single true/false value.
A compact way of saying what ||
does is:
true || true = true
false || true = true
true || false = true
false || false = false
OR is used to check that at least one requirement is met.