There may be times when you want to stop going through a loop early. To do that, you can use the break keyword:

for( let i = 0; i < 5; i++) {
  if (i === 3) {

In that example, we say that if our i variable is 3, we want to break out of the loop. So, that loop will print three numbers to the console: 0, 1, and 2.

Once you break out of a loop, you can't re-enter, so make sure you really want to break out of the loop.

If you have any questions about using break, you can also read about it in this blog post.


I finished! On to the next chapter