Hint
Closures capture the variable from their specific lexical scope, not outer scopes with the same name.
let x = 'global';
function outer() {
let x = 'outer';
function inner() {
console.log(x);
}
return inner;
}
const fn = outer();
x = 'changed';
fn();outer
Explanation: inner closes over the x in outer's scope ('outer'), not the global x. Even though global x changed to 'changed', inner's closure references outer's x which never changed.
Key Insight: Closures capture the variable from their specific lexical scope, not outer scopes with the same name.