A closure lets an inner function remember the variables around it. A counter is the clearest beginner example because each call proves the function kept its previous state.
function makeCounter() {
let count = 0;
return function () {
count += 1;
return count;
};
}
Return an inner function that updates count each time it runs.