How can I make var a = add(2)(3); //5 work?

You need add to be a function that takes an argument and returns a function that takes an argument that adds the argument to add and itself.

var add = function(x) {
    return function(y) { return x + y; };
}

Leave a Comment