Variables
Assigning values
Assigning a value means to store some data into a variable or constant. Values are assigned using a
single = sign and the variable being assigned to should be on the left side of the =.
Variables can be "reused" by assigning new values.
let userName = "unspecified"; userName = "Rick"; userName = "Morty";
Constants can only be assigned to once when first declared.
const pi = 3.14159;
Accessing values
To access a value means to retrieve the value stored in a variable. To access a value, just use the
variable in place of a hard-coded value.
The value stored in num
is accessed and stored into the variable numTwo
.
let num = 25; let numTwo = num;