Lesson ยท 8 min
Variables
Names for values
A variable is a name that points to a value. You create one with const or let.
const city = 'Lisbon';
let temperature = 18;
console.log(city);
console.log(temperature);
Use const for a value that will not change. Use let for a value that will change. If you try to change a const, JavaScript stops with an error.
let score = 10;
score = 12; // allowed: score was made with let
Template strings
A template string uses backticks instead of quotation marks. It lets you put a value inside the text with ${ }.
const name = 'Sam';
console.log(`Hello, ${name}!`);
The backtick key is usually at the top left of the keyboard, below the Esc key.
Your turn
Follow the three tasks. Each task is checked on its own.
Tasks
3 to do
Task 1, not checked yet. Make a constant named
planetwith the textMars.Task 2, not checked yet. Make a variable named
visitorswith the number3. On the next line, change it to4.Task 3, not checked yet. Print the sentence
Mars has 4 visitors today.Build it with a template string that usesplanetandvisitors.
Task 1 of 3
Make a constant named planet with the text Mars.