Course Content
Introduction to JavaScript
Challenge: Stop and Skip
Task
Implement a loop that skips even iterations and stops on the 5th iteration.
- You need to stop the loop at 5th iteration.
- The loop should output an iteration number to the console for each iteration.
- The word
"Skip"
should output to the console if the loop skips an iteration. - 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
2. Insert the
3. Output the
4. Insert the
5. Output the
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