JavaScript & TypeScript / Quiz
The switch That Fell Through
if/else chains on status codes, switch fall-through, grouped cases, and an empty array that turns out to be truthy.
- Difficulty
- Easy
- Format
- Quiz
- Points
- 100
- Estimate
- 7 min
// MISSION BRIEF
Your Mission
Branching decides which lines run. The traps are a missing break, the order of the conditions, and values that are truthy when you expected them not to be.
For each snippet, predict exactly what Node prints. If the code throws, pick the error. Run nothing: read it the way the engine does, top to bottom.
Speed bonus active.
// FIRST CONTACT
Battle teaser
What does this print? If it throws, pick the error. let statusCode = 404; if (statusCode === 200) { console.log("OK"); } else if (statusCode === 404) { console.log("Not found"); } else { console.log("Unexpected"); }
- ANot found, then Unexpected
- BNot found
- CUnexpected
- DOK
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
javascriptfundamentalscontrol-flowswitchtruthiness