break exits the loop, continue skips to the next iteration:
break
continue
for i in 0..10 { if i % 2 == 0 { continue } // skip evens if i > 7 { break } // stop at 7 print(i) // 1, 3, 5, 7 }
Goal: Print only the multiples of 3 between 1 and 30.
Run the code to see the output
9 results