How much cash? 50000 How much credit do you have? 75000 Enough to buy this car!
When execution gets to the if
statement, it finds that
cash >= 25000 --- is true, because 50000 >= 25000
also that
credit >= 25000 --- is true, because 75000 >= 25000
Since OR requires only a single true, the logical expression is 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.
Here is how ||
works:
true || true = true
false || true = true
true || false = true
false || false = false
OR checks that at least one requirement is met.