Variables Continued
We mentioned that we can also change the value of a variable. This applies to variables created with the let
or var
keywords. Variables created with the const
keyword cannot be changed. They are constants. Therefore, they are used only when we do not want to change the variable. For example:
const myName = "Roman";
If we tried to overwrite the value of a constant variable, the program would show an error message.
The last type of variables are those created using the var
keyword. The var
variables have been in JavaScript the longest, but they are problematic, which is why they were replaced by let
variables, which are now the standard. If you want to read an English article about var
variables, you can do so here. In this course, we will use only let
and const
variables.
Instructions
Create a variable score
using the let
keyword and assign it the value 0
.
On the next line, change the value of the score
variable to 1
.
On the next line, print the value of the score
variable.
Start programming for free
8/10