A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-103.js
1functionmultiply(a){
2returnfunction(b){returna*b;};
3}
4constdouble=multiply(2);
5consttriple=multiply(3);
6console.log(double(5),triple(5));
Scope
Answer & explanation
Console output
10 15
Why
Each call to multiply creates a separate closure that captures its own a, so double and triple snapshot 2 and 3 independently. Applying each to 5 then yields 10 and 15 because the captured a differs per closure. This is the essence of partial application: fixing some arguments now and supplying the rest later.