37 lines
900 B
Markdown
37 lines
900 B
Markdown
# looper blocks activity
|
|
|
|
Welcome! This activity will teach how to display a series of numbers for a for loop. Let's get started!
|
|
|
|
Let's create a for loop where `0` is the loop's starting value, `i` is the index variable, and `5` is the ending value. The index variable `i` starts at 0 and increases by 1 each time through the loop. The loop ends when `i = 5`.
|
|
|
|
|
|
```blocks
|
|
for (let i = 0; i < 6; i++) {
|
|
|
|
}
|
|
```
|
|
|
|
We will show the number of times the loop has been executed. It will go from zero to five times.
|
|
|
|
```blocks
|
|
for (let i = 0; i < 6; i++) {
|
|
basic.showNumber(i)
|
|
}
|
|
```
|
|
|
|
The for loop while cycle through to six immediately unless we pause for a little bit in between each loop.
|
|
|
|
```blocks
|
|
for (let i = 0; i < 6; i++) {
|
|
basic.showNumber(i)
|
|
basic.pause(2000)
|
|
}
|
|
```
|
|
|
|
### ~avatar avatar
|
|
|
|
Excellent, you're ready to continue with the [challenges](/lessons/looper/challenges)!
|
|
|
|
### ~
|
|
|