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"); }

  1. ANot found, then Unexpected
  2. BNot found
  3. CUnexpected
  4. DOK
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

javascriptfundamentalscontrol-flowswitchtruthiness