Complete the code to break out of the outer loop using a label.
OuterLoop: for i := 0; i < 3; i++ { for j := 0; j < 3; j++ { if i == 1 && j == 1 { [1] OuterLoop } println(i, j) } }
In Go, break with a label exits the labeled loop.
Complete the code to continue the outer loop when a condition is met.
Outer: for i := 0; i < 3; i++ { for j := 0; j < 3; j++ { if i == 1 && j == 1 { [1] Outer } println(i, j) } }
Using continue with a label skips to the next iteration of the labeled loop.
Fix the error by choosing the correct keyword to break the labeled loop.
Loop1: for x := 0; x < 5; x++ { for y := 0; y < 5; y++ { if x*y > 6 { [1] Loop1 } println(x, y) } }
The break keyword with a label exits the labeled loop correctly.
Fill both blanks to continue the outer loop and break the inner loop correctly.
OuterLoop: for i := 0; i < 3; i++ { InnerLoop: for j := 0; j < 3; j++ { if j == 1 { [1] OuterLoop [2] InnerLoop } println(i, j) } }
continue OuterLoop skips to the next iteration of the outer loop, and break InnerLoop exits the inner loop.
Fill all three blanks to break the outer loop, continue the inner loop, and break the labeled loop correctly.
Label1: for a := 0; a < 3; a++ { Label2: for b := 0; b < 3; b++ { if a == 1 && b == 1 { [1] Label1 } if b == 0 { [2] Label2 } if a == 2 { [3] Label1 } println(a, b) } }
break Label1 exits the outer loop, continue Label2 skips to the next inner loop iteration, and break Label1 again exits the outer loop.