JavaScript basics: Mutable values
let allows a value to change; choose it when reassignment is part of the task.
Current edit
Understand the pattern
let allows a value to change; choose it when reassignment is part of the task.
let allows a value to change; choose it when reassignment is part of the task.
Misconceptions to reject
- A string containing code executes automatically when it is assigned.
- A successful element lookup guarantees that the rest of an event handler is correct.
This is a code-inspection lab, not a full JavaScript runtime.
Worked example and expected result
let completed = 0;
completed = completed + 1;
const remaining = 3 - completed;let allows a value to change; choose it when reassignment is part of the task.
Explain it
Apply it elsewhere
Keep the momentum.
Complete the lab, then explain and apply the pattern.
Next: JavaScript basics: Readable stringsTry an incident drillAnonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.
Keep learning
- 01JavaScript basics: Constantsconst prevents reassignment of a binding. It does not deeply freeze an object stored in that binding.Practice
- 02JavaScript basics: Readable stringsStrings represent text; quotes delimit the value, while concatenation combines text without changing its meaning.Practice
- 03JavaScript basics: Number calculationsArithmetic operates on numbers. Converting units explicitly keeps an otherwise correct expression from answering the wrong question.Practice