Skip to main content

Logical Operators

When a decision depends on more than one test, logical operators let you combine the results or flip them:

  • && Logical AND - gives true only when both sides are true. Example: x < 5 && x < 10
  • || Logical OR - gives true when at least one side is true. Example: x < 5 || x < 4
  • ! Logical NOT - flips the outcome, turning true into false and false into true. Example: !(x < 5 && x < 10)