pxt-calliope/docs/lessons/looper/activity.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

37 lines
898 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)!
## ~