Learn
The or
logical operator is denoted by ||
.
It returns true
when the condition on the left is true
or the condition on the right is true
. Only one of them needs to be true
.
Here’s the truth table:
a | b | a || b |
---|---|---|
false | false | false |
false | true | true |
true | false | true |
true | true | true |
For instance:
( 1 < 2 || 2 > 3 )
returnstrue
( 1 > 2 || 2 > 3 )
returnsfalse
Note: The keyword or
can be used in the place of ||
.
Instructions
1.
Write the following if
statement:
- If
day
is equal to 6 orday
is equal to 7, then print the word"Weekend"
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.