We can declare variables to store data by using the var, let, or const keywords.

Practical Tasks

Please attempt these tasks on your own first, as this will cement your understanding. Only look at the solution if you are stuck or want to compare your solution.

Task 1: Working with variables

  1. Declare two variables: admin and name.
  2. Assign the value "John" to name.
  3. Copy the value from name to admin.
  4. Show the value of admin using console.log (must output “John”).


Task 2: Giving the right name

  1. Create a variable with the name of our planet. How would you name such a variable?
  2. Create a variable to store the name of a current visitor to a website. How would you name that variable?


Task 3: Uppercase const?

Examine the following code:

const birthday = '18.04.1982';

const age = someCode(birthday);

Here we have a constant birthday date and the age is calculated from birthday with the help of some code (it is not provided for shortness, and because details don’t matter here).

Would it be right to use upper case for birthday? For age? Or even for both?