Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

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 *