</> CodeWithMe
Sign in
← ⚡ JavaScript from Scratch

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

  1. Declare a variable score with let and the value 10.
  2. Increase it by 5.
  3. Print score to the console.