Give the While loop a condition so it stops instead of repeating forever.
This tutorial is part of the Nairda learning path. You can build it step by step inside the app, which checks every block you place before letting you move on.
The steps
- We create a number variable called n.
- We add a While loop.
- We put a comparison in its condition and choose less than.
- The comparison says n is less than 3, so the loop ends.
- Inside the loop we add a Set for the variable n.
- We give it a sum that adds 1.
- The sum takes the current value of n, so it grows each turn.
- Behind it we wait one second, to watch it count.
- On the dashboard we draw a label.
- And we drag the variable n onto the label.
When you finish, the app takes you straight to the next tutorial in the path.