15 min +50 XP
Lesson 25Step 1 of 5

Logical Operators

Combine conditions with &&, ||, and !

What are Logical Operators?

Logical operators let you combine multiple conditions. They're like the words "and", "or", and "not" in programming!

&&

AND

Both must be true

||

OR

At least one must be true

!

NOT

Reverses true/false

Quick Example

javascript
1
2
3
4
5
6
7
8
9
10
11
12
const age = 20
const hasLicense = true
 // AND: Both must be true
if (age >= 18 && hasLicense) {
  console.log('You can drive!')  // This runs
}
 // OR: At least one must be true
if (age >= 21 || hasLicense) {
  console.log('Special access!')  // This also runs
}