Javascript - break and continue
Code Life
By Pierre Marsaa
Leaving a Loop Early with break
Sometimes you want to stop a loop before its natural end: you found what you were looking for, the battle is already won... The break keyword exits the loop immediately. You already met it in switch!
↗️
Loading editor...
↶
↷
The loop was planned for 10 turns, but break stops it at turn 3. The remaining turns never happen, and the program continues right after the loop.
Verify