>_Code Club
← All exercises

javascript

Variables and template strings

JavaScript has two main ways to create a variable:

const planet = "Earth";   // const: this value will never be replaced
let score = 0;            // let: this value can change later
score = score + 10;

Use const by default, and let only when you know the value will change.

To put variables inside text, use backticks ` (not quotes!) and ${...}:

console.log(`Welcome to ${planet}! Your score is ${score}.`);

Your mission

  1. Create a const called name with your name.
  2. Create a const called age with your age (a number).
  3. Print My name is ... and I am ... years old. using a template string.
Next exerciseFunctions →
Loading the editor…