Currying in javascript


Problem

Implement the compound function which returns a function and satisfies the following condition

function add10 (a) {
  return a + 10
}

console.log(add10(10)) // 20
console.log(compound(add10)(10)) // 30

Understanding closures, currying, partially applied functions in javascript is pre-requisite before seeing the solution. I would recommend reading that article first.


Solution


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons