Tsallaka zuwa abun ciki
Justice Tech School

Loop Control: break, continue and labels

break leaves a loop and continue skips to the next round. Labels let you exit nested loops. Avoid infinite loops by changing the condition.

Example
outer: for (let i = 0; i < 3; i++) {
  for (let j = 0; j < 3; j++) {
    if (j === 1) continue;
    if (i === 2) break outer;
    console.log(i, j);
  }
}

Exercise

Skip this round.

;

Quiz Test

What does continue do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.