Variables are used to store things.
When to use
You'll use variables ALL the time. Anytime you need to store data, you'll use variables.
To create a variable, you need to declare it using the var keyword:
To add things to variables, use the equal to sign:
myVariable = "Something";
You can declare and assign at the same time:
var myVariable = "Something";
Variable names can include letters, numbers, dollar signs, and underscores; but not dashes (-).
Hints & tips
- Variables are used to store data.
- Declare them first, then add stuff to them.
Lesson notes are only available for subscribers.