Hint
All three functions share the same i variable β and i is 4 after the loop ends.
function makeAdders() {
const adders = [];
for (var i = 1; i <= 3; i++) {
adders.push(function(x) { return x + i; });
}
return adders;
}
const [add1, add2, add3] = makeAdders();
console.log(add1(10));
console.log(add2(10));
console.log(add3(10));14 14 14
Explanation: All functions close over the same var i. After the loop, i = 4 (incremented past condition). So all return 10 + 4 = 14.
Key Insight: All three functions share the same i variable β and i is 4 after the loop ends.