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
1
const name = "Ada";2
let score = 82;3
score += 9;4
console.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
| Step / line | What happens | State after step | Output 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 |