JavaScript Variables

Use const and let for values.

JavaScript
const name = "Ada";
let score = 82;
score += 9;
console.log(name, score);
Output
Ada 91

Explanation

Use const when you will not reassign a binding. Use let when reassignment is needed. Prefer clear names and avoid var in new code.

Explore the dry run
Guided walkthroughReady
1const name = "Ada";
2let score = 82;
3score += 9;
4console.log(name, score);

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Bind name to Ada.name = "Ada"
—
Initialize score to 82.score = 82
—
Add 9 and assign the result back to score.score = 91
—
Log both values.score = 91
Ada 91