Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

Logical Operators (AND, OR, NOT)

Logical operators combine multiple conditions.

AND Operator (&&)

Returns true only when BOTH conditions are true:

age >= 18 && hasLicense  // must be 18 AND have license

Truth table:

  • true && true = true
  • true && false = false
  • false && true = false
  • false && false = false

OR Operator (||)

Returns true when AT LEAST ONE condition is true:

isWeekend || isHoliday  // weekend OR holiday

Truth table:

  • true || true = true
  • true || false = true
  • false || true = true
  • false || false = false

NOT Operator (!)

Returns the opposite:

!isRaining  // NOT raining (so it's dry)

Grouping with Parentheses

Control evaluation order:

hasCard && (age >= 18 || hasPermission)
// Must have card AND (be 18 OR have permission)