Currying is the technique of converting a function that takes multiple arguments into a sequence of functions that each takes a single argument.
Implement curry(fn) to return a curried version of fn. Collect one argument at a time until at least fn.length arguments have been provided, then call fn with the collected arguments.
Calls with no arguments should be ignored and return another function. Preserve the this value from the first call in the chain when fn is finally invoked.
fn (Function): The function to curry.(Function): Returns the curried function.
function add(a, b) {return a + b;}const curriedAdd = curry(add);curriedAdd(3)(4); // 7const alreadyAddedThree = curriedAdd(3);alreadyAddedThree(4); // 7
function multiplyThreeNumbers(a, b, c) {return a * b * c;}const curriedMultiplyThreeNumbers = curry(multiplyThreeNumbers);curriedMultiplyThreeNumbers(4)(5)(6); // 120curriedMultiplyThreeNumbers()(4)()(5)(6); // 120const containsFour = curriedMultiplyThreeNumbers(4);const containsFourMulFive = containsFour(5);containsFourMulFive(6); // 120
console.log() statements will appear here.