Explorer
Node.js

Write a `partial(fn, ...presetArgs)` function that pre-fills some arguments of `fn`.

Problem Statement

Write a `partial(fn, ...presetArgs)` function that pre-fills some arguments of `fn`.

Complexity

Time Complexity: -

Space Complexity: -

Hints

šŸ’” Hint 1: Partial application fixes some arguments and returns a new function for the rest. šŸ’” Hint 2: Return a function that takes the remaining args and calls fn with all args. šŸ’” Hint 3: return (...laterArgs) => fn(...presetArgs, ...laterArgs); āœ… Solution: ```javascript function partial(fn, ...presetArgs) { return (...laterArgs) => fn(...presetArgs, ...laterArgs); } ```

Partial Application

Medium
Write a `partial(fn, ...presetArgs)` function that pre-fills some arguments of `fn`.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
[10,35]