...

/

Solution Review: Let's Curry!

Solution Review: Let's Curry!

This lesson will explain the solution to the problem in the previous lesson.

Solution #

Press + to interact
function currying(func) {
function curriedfunc(...args) {
if(args.length >= func.length) {
return func(...args);
} else {
return function(...next) {
return curriedfunc(...args,...next);
}
}
}
return curriedfunc;
}
function multiply(a, b, c) {
return a*b*c;
}
let curried = currying(multiply);
console.log(curried(2)(3)(4))
console.log(curried(2,3)(4))
console.log(curried(2,3,4))
console.log(curried(5)(6,7))

Explanation

...
Access this course and 1400+ top-rated courses and projects.