Variables: let, const and why not var
A variable is a name for a value. const makes a name that cannot be reassigned; let makes one that can. Default to const — it tells the reader "this does not change" — and reach for let only for counters and accumulators. var is the 1995 version: it ignores block scope and is hoisted in a way that hides bugs, so modern code does not use it.
You should see
Ada 2
{ name: 'Grace' }
undefined everywhere
3 Adaconst and try to reassign it. Read the error. Then change it to let.TypeError: Assignment to constant variable
const total = 10
total = 20Uncaught TypeError: Assignment to constant variable.
at your code:2You declared total with const, which promises it will never be reassigned. The engine holds you to it.
If the value genuinely changes, declare it with let. If you only meant to change a property inside an object or array, that is allowed with const — see above.
let total = 10
total = 20
console.log(total)ReferenceError: x is not defined
const price = 100
console.log(prcie * 2)Uncaught ReferenceError: prcie is not defined
at your code:2The engine looked for a variable called prcie and there is none — a typo. JavaScript is case-sensitive too: Price and price are different names.
Read the name in the error character by character. Editors underline undefined names as you type; use one.
