Trouble with currying function

I’m having trouble currying a function if only one argument is passed to the function. I’m returning a reference to another function when a second argument is passed.

If the function invocation is changed to addTogether(2)(3), I get the following error: TypeError: addTogether(...) is not a function.

Your code so far

function addTogether() {
  function valid_arg(value) {
    return Number.isInteger(value) ? value : undefined;

  var args =;
  if (args.every(valid_arg) && args.length === 2) {
    return arguments[0] + arguments[1];
  } else {
    return undefined;

  function add(y) {
    if (valid_arg(y)) {
      return arguments[0] + y;
    return undefined;
  return add;

addTogether(2, 3);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0.

Challenge: Arguments Optional

Link to the challenge:

I’m not sure about the specific issue here, but I recommend defining two parameters (eg x, y) on addTogether so that you don’t have to bother with the arguments object, which is a bit of a pain to work with (as I’m sure you can tell). Just glancing at this, the thing that concerns me is that arguments[0] in the local add function, does that refer to the addTogether arguments as you expect? Or does it refer to add’s arguments?

I realized I had to declare x = arguments[0] in the scope of addTogether and pass that into the function body of add.