pxt-calliope/docs/lessons/looper/activity.md

37 lines
898 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# 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
2016-03-26 00:47:20 +01:00
2016-04-13 17:27:45 +02:00
Excellent, you're ready to continue with the [challenges](/lessons/looper/challenges)!
2016-03-26 00:47:20 +01:00
## ~
2016-03-26 00:47:20 +01:00