Arguments optional. Passed but with some doubt... [SPOILER]

Hi campers! After a long struggle I managed to pass this algorithm challenge, but I’ve got some doubt. With the following code the challenge is succesfully passed but when i call the function with a single argument it will return function (x) {return .......} instead of a number, also if I set a value for the x variable. I’ve noticed that the same issue is common to all the solutions given in the relative wiki. Any suggestion on how to make it work the right way also with a single argument?

function addTogether(args){    
  if(arguments.length == 1 && typeof arguments[0] == "number") {      
    return function(x) {
      return addTogether(args, x);
  if(arguments.length == 2 && typeof arguments[0] == "number" && typeof arguments[1] == "number") {
    return arguments[0] + arguments[1];


The assignment says:

Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.

You should return a function. Read on closures.

Thanks, @jenovs. I’ve read a lot of times that MDN page… I thought that I as missing some line of code to call that function directly inside the addTogether function, and then return the result of the closure.