let and const
Declare variables with let (can change) and const (cannot be reassigned):
const name = "Anna";
let score = 0;
score = score + 10;
console.log(name, score); // Anna 10
Shorthand: score += 10 is the same as score = score + 10.
Challenge
- Declare a variable
scorewithletand the value10. - Increase it by
5. - Print
scoreto the console.