×

typescript · level 1 · unit 5 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

stops a loop early. skips a turn.

Sometimes you want out of a loop before it finishes. break jumps straight out, like leaving a queue. The program carries on after the loop.

continue is gentler. It skips the rest of this lap and goes on to the next one, like a lift that does not stop at floor 13.

Both of them usually live inside an if, so they only happen at the right moment.

for (let floor = 10; floor <= 16; floor++) {
  if (floor === 13) {
    continue;
  }
  console.log("Ding! Floor", floor);
}

break and continue end with a semicolon, like every other instruction.