30 Days Of JavaScript

Day 4: Loops

Lesson 5: Continue

Similar to break this command skips the rest of that loop iterations code. But doesn't end the loop.

So, with the example from before:

In this case you can see that 11 isn't logged, because the loop has ended before it can print it. Rather than exiting the loop though it goes to the next iteration.

A practical use for this would be creating a filter, like this:

.push(age) is a way to add an element to the end of an existing JavaScript array. Notice how adding the age to the filtered array doesn't remove it from the first array. This means we can make new copies of our data and work in a safe way without loosing what we started with.


Go Pro?

Upgrade to Pro for quizzes, tracked progress and a completion certificate for just $25 🚀

Want more developer tips, tricks and tools?
Then follow me:
FREE Coding Career Quick Start Guide 🚀
Discover the best way to learn to code, how to land a job and valuable resources to help your journey in this free 15 page value packed guide.
Looking to email me? You can get me on my first name at allthecode.co