Curry a Function
Write the code, see it run, pass the checks.
The problem
- medium
- Code
Write curry(fn): return a curried version that collects arguments over one or more calls, in any grouping, and calls fn once it has at least fn.length of them, passing every argument collected and returning fn's result. Until then each call returns a new function waiting for the rest. Partial calls must be reusable: calling the same partly filled function twice starts both from the same arguments. A function with fn.length of 0 runs on the first call.
Your code must pass
- Collects arguments one at a time
- Accepts the arguments in any grouping
- Each partly filled function can be reused
- Passes on extra arguments and handles fn.length of 0