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. function add(x, y) {
  2.    return x + y;
  3. }

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. function add(x) {
  2.    return function (y) {
  3.       return x + y;
  4.    }
  5. }

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.