The counter: a box that keeps a number
Section 2: VariablesLesson 2.1 · ⏱ 10 min
A variable is a box with a name that keeps a number. The app remembers it and changes it. Here its name is count.


- set count to 0 when the app opens: counting starts from zero.
- change count by 1 adds one, and by -1 takes one away.
- After the change we show the number in Label1, otherwise we won't see it.
📌 Another example: a counter that steps by 5, and a zero button
+5 adds five, and “Zero” takes the counter back to the start.



Test yourself
✍️ Practise
The challenge: the counter.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
✍️ Practise
Practice: plus and minus.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
A counter that adds 2 with every tap.
👀 Show the solution🙈 Hide the solution



Result: after 3 taps: 6
Medium
A countdown counter: it starts at 10 and takes away 1.
👀 Show the solution🙈 Hide the solution



Result: after 3 taps: 7
Hard
When the counter reaches 10 or more the screen turns green.
👀 Show the solution🙈 Hide the solution



Result: at 10 the screen turns green.

