Complete the code to stop the loop when i equals 3.
for i in 1...5 { if i == 3 { [1] } print(i) }
The break statement stops the loop immediately when the condition is met.
Complete the code to skip printing the number 3 but continue the loop.
for i in 1...5 { if i == 3 { [1] } print(i) }
The continue statement skips the current iteration and continues with the next one.
Fix the error in the loop to correctly skip the number 2 and stop at 4.
for i in 1...5 { if i == 2 { [1] } if i == 4 { break } print(i) }
Use continue to skip printing 2, and break to stop at 4.
Fill both blanks to skip odd numbers and stop the loop when i is 8.
for i in 1...10 { if i [1] 2 != 0 { [2] } if i == 8 { break } print(i) }
Use % to check if a number is odd and continue to skip it.
Fill all three blanks to print only even numbers less than 7.
for i in 1...10 { if i [1] 2 != 0 { [2] } if i [3] 7 { break } print(i) }
Check if number is odd with %, skip with continue, and stop loop when i ≥ 7 using >=.
