In this video,
you'll add variables to store the votes
for each item on your fashion poll.
Computer scientists use variables
frequently in programs to store values
that will be displayed or used later.
You'll need a variable to indicate
how many people voted for items on your poll.
To add a variable select a sprite to track.
This example uses the yellow sneakers.
Next click on the data menu
and click the make a variable button.
Name the variable something that makes sense
for the sprite you selected.
In this example it's called sneakers.
The name will be displayed below the sprite.
This variable will store the vote count
for the yellow sneakers.
Then place the variable read out under the sprite.
Drag the change variable by one block
into the scripts editor.
Click the change by one block.
The variable value will increase by one
each time you click the block.
However nothing happens when you click the sprite.
You still need to click the code block itself.
Click on the events menu
and add a when the sprite is clicked event.
Now each time you click the sprite
the value of the variable should increase by one.
Now you'll be able to keep track
of every vote cast for this sprite.
Next create the same code
for the other sprites in your poll
by adding a new variable and tracking the clicks
for each sprite.
Now it's your turn.
For each sprite make a variable
and add the code to change the variables value by one
each time the sprite is clicked.
Remember to test your code frequently as you work.
That's how computer scientists find problems early
before they have created too much more code.
Sign in to save your project and track your progress.