Test your skills: variables

The aim of this skill test is to assess whether you've understood our Storing the information you need — Variables article.

Note: You can try solutions in the interactive editors on this page or in an online editor such as CodePen, JSFiddle, or Glitch. If there is an error in your code, it will be logged into the results panel on this page or in the JavaScript console.

If you get stuck, you can reach out to us in one of our communication channels.

Variables 1

In this task we want you to:

  • Declare a variable called myName.
  • Initialize myName with a suitable value, on a separate line (you can use your actual name, or something else).
  • Declare a variable called myAge and initialize it with a value, on the same line.

Try updating the live code below to recreate the finished example:

Download the starting point for this task to work in your own editor or in an online editor.

Variables 2

In this task you need to add a new line to correct the value stored in the existing myName variable to your own name.

Try updating the live code below to recreate the finished example:

Download the starting point for this task to work in your own editor or in an online editor.

Variables 3

The final task for now — in this case you are provided with some existing code, which has two errors present in it. The results panel should be outputting the name Chris, and a statement about how old Chris will be in 20 years' time. How can you fix the problem and correct the output?

Try updating the live code below to recreate the finished example:

Download the starting point for this task to work in your own editor or in an online editor.