Learn

The and logical operator is denoted by &&.

It returns true if the condition on the left and the condition on the right are both true. Otherwise, it returns false.

Here’s the truth table:

a b a && b
false false false
false true false
true false false
true true true

For instance:

  • ( 1 < 2 && 2 < 3 ) returns true
  • ( 1 < 2 && 2 > 3 ) returns false

Note: The keyword and can also be used in the place of &&.

Instructions

1.

Write the following if statement:

  • If hunger is true and anger is true, then print out the word "Hangry".

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?