
Scope determines where a variable is accessible. A variable declared outside any function is global — accessible everywhere. A variable declared inside a function is local — accessible only within that function. let and const are also block-scoped, meaning they are confined to the nearest pair of curly braces. Keeping scope tight prevents bugs.
Reference:
TaskLoco™ — The Sticky Note GOAT