If Else If Chain
Predict Output Easy
Question
What does this code print?
Code
let temp = 25;
if (temp > 30) {
console.log("hot");
} else if (temp > 20) {
console.log("warm");
} else {
console.log("cool");
}
Hint
Check each condition in order.
Explanation
temp is 25. The first condition temp > 30 is false (25 <= 30). The second condition temp > 20 is true (25 > 20), so "warm" is printed. The else branch is skipped. The output is: warm
Related Resources
Related Lessons
- Conditions (if/else)
Learn how if/else conditions work.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.