Tsallaka zuwa abun ciki
Justice Tech School

break, continue and Labels

break leaves a loop and continue skips. Labels target outer loops.

Example
outer:
for (var i = 1; i <= 3; i++) {
  for (var j = 1; j <= 3; j++) {
    if (j == 2) continue;
    if (i == 3) break outer;
    print("$i $j");
  }
}

Exercise

Skip a round.

;

Quiz Test

What does break outer do?

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