Learn
Home stretch! Let’s go over boolean operators.
( 1 == 1 ) && ( 2 == 2 ) # true ( 1 == 2 ) || ( 2 == 2 ) # true !( false ) # true
- With
&&
both comparisons on the left and right must evaluate totrue
for the entire statement to returntrue
. If the left side does not returntrue
it will not bother trying the right side - With
||
either the right or left side must evaluate totrue
. If the left side evaluates totrue
, the right side will not be tried because it has met the condition of one side beingtrue
. - With
!
you reverse the result. If you’refalse
you’re nowtrue
. if you’retrue
you’re nowfalse
! Just think of it as opposite day!
Instructions
1.
The code in the editor indicates what value (true
or false
) we want each variable to have, and your job is to add an expression that evaluates to the correct value using boolean operators (&&
, ||
, or !
).
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.