JavaScript & TypeScript / Quiz

for, for...of, for...in, forEach: Pick the Loop

Counting loops, retry loops, break and continue, the difference between for...in and for...of, and why forEach cannot break.

Difficulty
Easy
Format
Quiz
Points
100
Estimate
7 min

// MISSION BRIEF

Your Mission

JavaScript offers several ways to repeat work, and they differ in what they hand you on each pass and in whether you can stop early.

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. for (let i = 0; i < 3; i++) { console.log(i); }

  1. A0, then 1, then 2
  2. B0, then 1, then 2, then 3
  3. C1, then 2
  4. D1, then 2, then 3
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

javascriptfundamentalsloopsiteration