A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-107.js
1functionbuild(a){
2return(b)=>(c)=>[a,b,c];
3}
4conststep=build(1)(2);
5console.log(step(3).join(""));
6console.log(step(9).join(""));
Scope
Answer & explanation
Console output
123
129
Why
Calling build(1)(2) captures a = 1 and b = 2 in a closure and returns the innermost function as step. Each call to step reuses those captured snapshots and only varies c, so step(3) yields [1,2,3] and step(9) yields [1,2,9]. The fixed earlier arguments persist across multiple invocations, which is the whole point of currying for reuse.