LESSON 10
Conditions
Learning objective: Understand how conditions control program flow.
Understand
Conditions let programs make choices.
A condition is any expression that evaluates to true or false. Based on it, your code can take different paths. Conditions are the gateway to if statements and loops.
Analogy: A condition is like a fork in the road: the answer decides which way you go.
See It in Action
A condition used in a check:
let temp = 30;
let hot = temp > 25;
console.log(hot); // trueHow it works: The comparison
temp > 25 is the condition; it produces a boolean that decides what happens next.Try It Yourself
- Write a condition comparing two numbers.
- Store the result in a variable.
- Log whether it is true or false.
Quick Quiz
What does a condition evaluate to?
Challenge
Write three conditions about a value and log each result.
Success condition: Each condition logs a correct true or false.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →