frontend-challenges
frontend-challenges copied to clipboard
449 - Curry - javascript
index.js
/**
* @param {Function} fn - original function to curry
* @returns {Function}
*/
export function curry(fn) {
return function curried(...args) {
if (args.length >= fn.length) {
return fn(...args);
}
return (...restArgs) => fn(...args, ...restArgs);
};
}