Arguments Optional failing last test

Arguments Optional failing last test
0

#1

Tell us what’s happening:

For some reason my function is failing the last test.

for addTogether(2)([3]), my function is returning 23 rather than undefined.

Any kind of nudge in the right direction would be greatly appreciated.

Your code so far

function addTogether(firstNum,secondNum) 
{
  for(var i = 0; i<arguments.length; i++)
  {
//     alert(typeof arguments);
    if(typeof arguments[i] !== "number"){return undefined;}
  }
  
  if(arguments.length < 2)
  {
    
    return function(secondNum){return firstNum+secondNum;};
    
  }
  else
  {
    return firstNum+secondNum;
  }


}

addTogether(2)([3]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:


#2

Hi @dayna-j

Have a look at where your checking to see if the value is a number or not.

If you get super stuck:

Your only checking if the value is a number at the top function. In the last test where the second function is called with an array, your not checking there and just adding the two values together.