LESSON 9
Booleans
Learning objective: Use true/false values to drive decisions.
Understand
Booleans represent yes/no, on/off states.
A boolean is either true or false. Comparisons produce booleans, and logical operators (&&, ||, !) combine them. Booleans are the basis of every decision your program makes.
Analogy: A boolean is like a light switch: it is either on or off.
See It in Action
Combining conditions:
let age = 20;
let ok = age >= 18 && age < 65;
console.log(ok); // trueHow it works:
&& requires both comparisons to be true, so ok is true only when age is between 18 and 65.Try It Yourself
- Store a boolean directly.
- Create one from a comparison.
- Combine two conditions with
&&.
Quick Quiz
What does the && operator require?
Challenge
Write a boolean expression that checks two conditions at once.
Success condition: Your expression returns true only when both conditions hold.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →