course content

Course Content

Introduction to JavaScript

Challenge: Stop and SkipChallenge: Stop and Skip

Task

Implement a loop that skips even iterations and stops on the 5th iteration.

  1. You need to stop the loop at 5th iteration.
  2. The loop should output an iteration number to the console for each iteration.
  3. The word "Skip" should output to the console if the loop skips an iteration.
  4. The word "Stop" should output to the console if the loop stops.

The output should be:

Hint
1. Put the counter name to the first console.log() function.

2. Insert the break operator to the if (i >= 5) code block.

3. Output the "Stop" string to the console before the break operator.

4. Insert the continue operator to the if (i % 2 == 0) code block.

5. Output the "Skip" string to the console before the continue operator.

Section 5.

Chapter 8