Problem
Write a generic curry(fn) that returns a curried version of fn.
You may call the curried function one argument at a time or pass several arguments in one call. Once enough arguments are collected (matching fn.length), invoke fn and return its result.
Input
const sum3 = (a, b, c) => a + b + c;
const curried = curry(sum3);
curried(1)(2)(3);
curried(1, 2)(3);
curried(1)(2, 3);
Expected output
All three calls return 6.
Implement:
function curry(fn) {
// Your code here
}