Your arguments are invalid.

Because it’s enough to have just one. See, thanks to scope and something called currying, any multi-argument function can be rewritten as a unary chained function. A simple example is this Javascript function to add two arguments:

1
2
3
function add(x, y) {
   return x + y;
}

it’s easy to see what that function would do, you pass in two arguments and they get added:

1
var sum = add(2, 3); // 5

now, in a functional world, you want to have unary functions that take only one argument. How can you achieve a simple add function if you’re not allowed to take more than one argument? This can be done by currying (and it requires scope)

1
2
3
4
5
function add(x) {
   return function (y) {
      return x + y;
   }
}

now the call to this method would be different because it just takes one argument. Thanks to the scope, the inner function can see the x, so you call this method like so:

1
var sum = add(2)(3); // 5

And that’s how you can decompose a multi-argument function into many, nested unary functions.