Break and Continue

Learn about the usage of break and continue keywords.

We'll cover the following

Introduction

We can use break or continue inside the loops:

  • break exits the closest loop it is in and continues with the next command,
  • continue skips out from the loop body and jumps back to the condition of the loop.

Example: sum every second element of the numbers array:

Get hands-on with 1200+ tech skills courses.