59 lines
861 B
Markdown
Raw Normal View History

2016-03-25 16:47:20 -07:00
# digi yoyo activity
Create a counter with a while loop.
## ~avatar avatar
2016-03-25 16:47:20 -07:00
Welcome! This tutorial will teach how to create a counter with a while loop. Let's get started!
## ~
2016-03-25 16:47:20 -07:00
Create a variable that acts as a counter and set it to 0.
```blocks
let count = 0
```
Add a while loop that will loop over and over until the variable `count` equals 10.
```blocks
let count = 0
while (count < 10) {
}
```
Let's add a pause. Then show the value of the the count.
```blocks
2016-04-13 08:51:40 -07:00
let count = 0;
2016-03-25 16:47:20 -07:00
while (count < 10) {
basic.pause(100);
basic.showNumber(count)
}
```
Increase the value of count by one.
```blocks
let count = 0
while (count < 10) {
basic.pause(100)
basic.showNumber(count)
2016-03-31 15:51:42 -07:00
count = count + (count - 1)
2016-03-25 16:47:20 -07:00
}
```
## ~avatar avatar
2016-03-25 16:47:20 -07:00
2016-04-13 08:27:45 -07:00
Excellent, you're ready to continue with the [challenges](/lessons/digi-yoyo/challenges)!
2016-03-25 16:47:20 -07:00
## ~
2016-03-25 16:47:20 -07:00