Lesson 4 of 5 · 8 minutes
Changing a variable's value
A variable made with let can receive a new value. This is
reassignment.
score = score + 1; reads the current score, adds one, and puts
the result back into the same box. The label stays. The value changes.
Use const when a value should not change. A const
box cannot be reassigned. This protects values that should stay fixed.
Same label, new value.
Loading the editor…
Run it twice. Each run starts the whole program again, so it prints 1 both times.
Quick check
You can now change a variable's value — and lock one with const when it should stay fixed.