What are Variables?
What are Variables?
Variables are the memory locations that are used to store data. In JavaScript, we use the let
, const
, and var
(var
is not used now) keywords to declare a variable.
By using let
we can re-assign the value to a variable. Values can not be reassigned if they are created using const
.
The following statement creates a variable named message
.
1let message;
Now we can assign some data to the variables by using the assignment operator sign (=
), for example.
12345let message; message = 'Hello'; // or you can do it in one line as well like this // let message = 'Hello'; console.log(message);
Swipe to start coding
Declare a variable named numberOfStudents
and assign the value 100
and display it on the console.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 2
What are Variables?
Sveip for å vise menyen
What are Variables?
Variables are the memory locations that are used to store data. In JavaScript, we use the let
, const
, and var
(var
is not used now) keywords to declare a variable.
By using let
we can re-assign the value to a variable. Values can not be reassigned if they are created using const
.
The following statement creates a variable named message
.
1let message;
Now we can assign some data to the variables by using the assignment operator sign (=
), for example.
12345let message; message = 'Hello'; // or you can do it in one line as well like this // let message = 'Hello'; console.log(message);
Swipe to start coding
Declare a variable named numberOfStudents
and assign the value 100
and display it on the console.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 2single