Module 5 · Lesson 3 of 419/32 in the course~16 min
Module lessons (3/4)
break and continue
Lesson preview5 hands-on exercises readyJavaScript Course · Module 5 — Control flow
Exit a loop early, or jump to the next iteration.
What you'll learn in this lesson
- Stop a loop as soon as an exit condition is found with
break. - Skip individual irrelevant elements while keeping the loop flow flat with
continue. - Understand the difference between
break(exits only the innermost loop) andreturn(exits the entire function). - Replace common patterns
break/continuein simple loops with.find()and.filter()when they improve clarity.
Overview
break and continue precisely control the internal execution of a loop: break immediately stops the innermost loop, while continue only stops the current iteration and jumps to testing the next one.
Sections covered in this lesson
- 1Mental model: early exit vs iteration skipping
- 2Progressive examples
- 3Guided laboratory
- 4Check for understanding
Pro Lesson · Module 5 — Control flow
Unlock "break and continue" and the full JavaScript Course curriculum
Exit a loop early, or jump to the next iteration.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in JavaScript Course plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.