Back to If / Then Challenge
Code Studio · Level 4

Real JavaScript Loops

A loop repeats one command for you. Choose a repeat limit, then watch one short block of JavaScript collect a whole row of stars.

Loop recipestart → check → act → add 1 ↻It stops when the check becomes false.
1. Choose the limit

How many stars should the robot collect?

STARTlet star = 1 KEEP GOINGstar <= 5 ADD ONEstar++

            

The same collectStar() command will run 5 times.

2. Watch every lap

The robot is ready at star 1.

COUNTERstar = 1
Robot collecting stars
Press Run the Loop
1. Check2. Collect3. Add 14. Repeat