Variables

A variable lets you store a single value in your computer's memory with a descriptive name. Using variables lets you easily refer to the same value many times in your program or save a number that you'd like to refer to later.

Creating Variables

The command var will create a new variable with the label that you give it. This variable has the label size.

Assigning Values

The assignment operator = will assign a new value to your variable. This command assigned 100 to the variable size. The variable must always be on the left side. You would read this command as "size gets 100" since size is getting a new value of 100. Any old values it might have been assigned are lost forever.

Using a Value

In order to use a variable's value, place its label in the spot in your code you want to use it. This command uses the value in size to set the width and height of the ellipse.

Initializing

Usually you'll want to give a variable its first (or "initial") value right away. You can initialize a variable in a single command by combining the var and = commands.

After you initialize a variable you don't need to use the var command to assign a new value. Just use the = as normal.

Found a bug in the documentation? Let us know at documentation@code.org