30 Days Of JavaScript

Day 4: Loops

Lesson 4: Break

Sometimes you will want to end a loop early. This is what break is for.

Not much to this, other than to say if you execute a break inside a loop it will end the loop and go to the next line of code after the loop.

In the code above you get 4 and 8, as soon as 11 === 11 is run, the break command jumps us out of the loop.

Outline

Go Pro?

If you upgraded to pro, sign in here

  • About
  • Blog
  • Privacy
Looking to email me? You can get me on my first name at allthecode.co