Predict Nested if Output
Predict Output Medium
Question
What does this code print?
Code
let x = 10;
if (x > 5) {
if (x > 15) {
console.log("big");
} else {
console.log("medium");
}
} else {
console.log("small");
}
Hint
Check the outer condition first, then the inner.
Explanation
x is 10. The outer condition x > 5 is true, so we enter the outer block. The inner condition x > 15 is false (10 is not > 15), so the inner else runs, printing "medium". The output is: medium
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.