Variables
A variable is a name for a value, so you can use it again later. You create one with let or const:
const name = "Tariro";
let score = 10;
score = score + 5;
console.log(name); // Tariro
console.log(score); // 15
constis for values that never change. Trying to change aconstis an error.letis for values that will change, like a score or a counter.score = score + 5reads as "take the old score, add 5, and store the result back in score".
Values have types. "Tariro" is a string (text, in quotes). 10 is a number (no quotes). The quotes matter: "10" is text that happens to contain digits.
You can join strings and numbers with +:
console.log(name + " scored " + score); // Tariro scored 15
Mind the spaces inside the quotes: + does not add any for you.
Your task
- Create a constant
citywith the value"Harare". - Create a variable
visitorsthat starts at1200. - On a new line, add
50tovisitors. - Print
Harare had 1250 visitorsusing your two variables.