A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-180.js
1constmake=()=>{
2conststore=[];
3returnv=>{store.push(v);returnstore.length;};
4};
5constpush=make();
6console.log(push("a"),push("b"),push("c"));
Scope
Answer & explanation
Console output
1 2 3
Why
The returned arrow closes over store, an array created once when make() ran, and that array stays alive as long as the closure exists. Each call appends to the same store, so the returned length increases through 1, 2, 3 across the three calls. A closed-over collection is the standard way to give a function persistent private state.