Skip to content
Advertisement

Boolean Currying Javascript

I am trying to write a boolean currying function in javascript.

JavaScript

I want isPresent function should return true if the passed arguments present is the given string else it should return false.

Advertisement

Answer

A generic solution is to have the “accumulator” value passed in differently. The first call you do to isPresent should already call the closure, and isPresent() should also work.

JavaScript

You can also write that with an IIFE:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement