Learning object 1 of 100
Variable value explorer
Step through a short program one statement at a time and watch each variable's box change. The values come from actually running your code with tracing turned on.
Loading…
What it shows
A variable is a named box. let and const create the box when their line runs; an assignment replaces the value inside. A const box (drawn with a double border) cannot receive a new value.
Guided experiment
- Press Step until score changes from 10 to 15.
- Change
score = score + 5toscore = score * 2and run again. Predict the final value first. - Add
const bonus = 3;and use it in the last line.
Predict
In the starting program, what value does score hold after line 3?
Related
Lessons: Lesson 2: Your first JavaScript program, Lesson 6: Variables with let and const
Projects: Project 9: Shopping Cart Price Calculator
Source: web/assets/js/objects/object-001.js in the companion repository.