How to Use the Continue Statement in JavaScript

The JavaScript continue statement offers an easy way to stop the current iteration of a loop and start a new one. In other words, it skips any remaining statements in a loop body--where a for loop or a while loop--and returns to the top for another go-around.

Things You'll Need

  • JavaScript editor
Show More

Instructions

  1. Use the Continue Statement in JavaScript

    • 1

      Code the continue statement at the point in the loop's body where you want to stop processing and start the next iteration. Example:
      for floor=1; i<110; i++) {
      if (floor == 13) continue;
      stop_at_floor (floor);
      }

Tips & Warnings

  • It's sometimes easy to confuse continue with break. Remember that break exits the loop completely, whereas continue simply restarts the next iteration.

Related Searches:

Comments

You May Also Like

Related Ads

Featured