break and continue, online

Six activities your students do on their own devices. See who's finished, and their scores.

break and continue in one minute

What students need to know

This exits the loop as soon as found becomes true. This skips the rest of the pass whenever x is even.

break stops the loop entirely, skipping any remaining passes. continue moves straight to the next pass without stopping the loop.

Mistakes students make

  • 'break' is the keyword to exit a loop, not 'stop'.
  • 'continue' is the keyword to skip a pass, not 'skip'.
  • 'break' must be lowercase - a capital B causes an error.
  • 'continue' must be lowercase - a capital C causes an error.

Discover other journeys with this module

What students will learn in this module

Every question in Module 21

Quick questions

  1. Does break exit a loop completely?ANoBYes
  2. Does continue skip the rest of the current pass only?AYesBNo
  3. Is 'stop' a valid keyword to exit a loop?ANoBYes
  4. Must 'break' be written in lowercase?ANoBYes
  5. Does continue stop the loop from running any more passes?ANoBYes

Key terms

Students type the meaning of:

  • break

Match the pairs

break;Match it to what it does
continue;Match it to what it does
Stops a loop early once a condition is metMatch it to what it does
Skips even numbers while loopingMatch it to what it does
if (i === 4) { stop; }Match it to what it does
if (i === 2) { skip; }Match it to what it does

Fill in the blanks

  1. if (i === 4) {
    _____;
    }

    Hint: Type the keyword that exits the loop completely.

  2. if (i === 2) {
    ________;
    }

    Hint: Type the keyword that skips to the next pass of the loop.

  3. if (n > 10) {
    _____;
    }

    Hint: Type the keyword that exits the loop completely.

  4. if (x % 2 === 0) {
    ________;
    }

    Hint: Type the keyword that skips to the next pass of the loop.

  5. if (found) {
    _____;
    }

    Hint: Type the keyword that exits the loop completely.

Spot the error

Question 1

Aif (i === 4) {Bstop;C}

Question 2

Aif (i === 2) {Bskip;C}

Question 3

ABreak;Bfor (let i = 0; i < 5; i++) {Cif (i === 3) {D}

Question 4

Afor (let j = 0; j < 5; j++) {Bif (j === 1) {C}DContinue;

Question 5

Afor (let k = 0; k < 5; k++) {Bif (k > 3) {Cconsole.log(k);D}Ebrek;