Back to Freecodecamp

Learn Variables and Operators Lesson B

curriculum/challenges/english/blocks/top-learn-variables-and-operators/65e18d61500d930ce8ed90a5.md

latest1.3 KB
Original Source

--description--

You can think of variables as "storage containers" for data in your code.

A variable is a "named storage" for data. You can use variables to store goodies, visitors, and other data.

To create a variable in JavaScript, use the let keyword.

The statement below creates (in other words: declares) a variable with the name "message":

js
let message;

Now, you can put some data into it by using the assignment operator =:

js
let message;

// store the string 'Hello' in the variable named message
message = 'Hello'; 

To be concise, you can combine the variable declaration and assignment into a single line:

js
let message = 'Hello';

--questions--

--text--

What is the purpose of using the let keyword in JavaScript?

--answers--

To perform mathematical operations.


To declare a constant value that cannot be changed.


To declare a variable that can store data, which can be assigned and changed.


To create a function.

--video-solution--

3