Cursos /
Introduction to JavaScript
Challenge: Stopping and Skipping
Task
Implement a loop that skips even iterations and stops on the 5th iteration. Here are the instructions:
- The loop should stop at the 5th iteration.
- For each iteration, output the iteration number to the console.
- If the loop skips an iteration, output the word
"Skip"
to the console. - If the loop stops, output the word
"Stop"
to the console.
The output should be:
- Include the counter variable in the first
console.log()
statement. - Use the
break
statement inside theif (i >= 5)
block to stop the loop. - Output the string
"Stop"
to the console before thebreak
statement. - Use the
continue
statement inside theif (i % 2 == 0)
block to skip even iterations. - Output the string
"Skip"
to the console before thecontinue
statement. - For other cases, output
"Successful"
to the console.
¿Todo estuvo claro?
Sección 5. Capítulo 8
Contenido del Curso
Introduction to JavaScript
4. Conditional Statements
Introduction to JavaScript
Challenge: Stopping and Skipping
Task
Implement a loop that skips even iterations and stops on the 5th iteration. Here are the instructions:
- The loop should stop at the 5th iteration.
- For each iteration, output the iteration number to the console.
- If the loop skips an iteration, output the word
"Skip"
to the console. - If the loop stops, output the word
"Stop"
to the console.
The output should be:
- Include the counter variable in the first
console.log()
statement. - Use the
break
statement inside theif (i >= 5)
block to stop the loop. - Output the string
"Stop"
to the console before thebreak
statement. - Use the
continue
statement inside theif (i % 2 == 0)
block to skip even iterations. - Output the string
"Skip"
to the console before thecontinue
statement. - For other cases, output
"Successful"
to the console.
¿Todo estuvo claro?
Sección 5. Capítulo 8