Last time, we looked at the rules for naming variables. Remember, variables are like labeled boxes for storing information.
If we write:
let playerLevel = 5;
Engagement Message
What value is stored inside the playerLevel
variable?
Let's quickly recap a key naming rule: variable names cannot contain spaces.
Engagement Message
So, if you wanted a variable for a user's age, would user age
be a valid name in JavaScript?
An important thing about variables is that their values can change! You can update the value stored in a variable by assigning a new value to it.
Example:
Engagement Message
What value does the level
variable hold after the third line (level = 2;
) is run?
Variables are especially useful when working with numbers because you can perform calculations with them.
JavaScript uses familiar symbols for math: +
for addition, -
for subtraction, *
for multiplication, and /
for division.
