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

Closures, currying, partially applied function interview question in javascript

Write a function say which logs the following.

console.log( say('Foo')('bar')() ) // => "Foo bar "

console.log( say('Hi')('my')('name')('is')('Foo')() ) // "Hi my name is Foo "

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

Note: Solution does not use recursion. There is a difference between recursion and function returning a function.


You may also like...

Leave a Reply

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