Implement curry(fn)
A classic functional-programming interview question that tests whether you actually understand closures, not just recognize the word "curry."
Write a function curry(fn) that transforms a function taking multiple arguments into one that can be called with arguments one at a time, several at once, or all at once — returning a new function until enough arguments have been supplied, at which point it calls the original fn and returns its result.
function add3(a, b, c) { return a + b + c; }
const curried = curry(add3);
curried(1)(2)(3); // 6
curried(1, 2