Category:Loops

Repeats a sequence of code a specified number of times.

Instead of writing the same code again and again, you can use a repeat loop. When a program is run and reaches the repeat loop, it will run the code inside of that loop the specified number of times. Once the repeat loop is finished, the program will continue from where it left off.

Examples

Example 1

The make a new sprite block is only used once, but repeating it five times allows five chemistry flask sprites to be created.

Example 2

Multiple lines of code can be used in a repeat loop, and a repeat loop can be used anywhere in a sequence of code.

Parameters

NameDescription
number The number of times the code will be repeated

Found a bug in the documentation? Let us know at documentation@code.org