var is function-scoped and hoisted. let/const are block-scoped. const prevents reassignment but allows object mutation.
Solution Code
JavaScript
if(true) { var a = 1; let b = 2; }
console.log(a); // 1
console.log(b); // ReferenceError
Explanation
Block scoping prevents variables from leaking outside their context. const maintains immutable binding.Guided Hints
What is temporal dead zone?
Can const objects be modified?