Arguments Optional im stuck

Tell us what’s happening:
Can someone tell me whats wrong with my code? I cant pass the test for addTogether(2)(3).

Your code so far


function addTogether() {
  
/* check if the argument is number  */
function checkIfNumber(num) {
  if (typeof num == "number") {
    return num;
  } else {
    return false;
  }
}
var a = checkIfNumber(arguments[0]);
var b = checkIfNumber(arguments[1]);
console.log(arguments.length);

if (arguments.length == 2) {
  if (a === undefined || b === undefined) {
    return undefined;
  } else if (a && b)  {    
    return a + b;
  }
} else if (arguments.length = 1) {
  var c = arguments[0];
  if (checkIfNumber(c)) {
    return function(arg2) {
      if (c === undefined || arg2 === undefined) {
        return undefined;
      }  else if (a && b ) {
        return c + arg2;
      }    
    }
  }
}


}

addTogether(2)([3]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional/

Remember the difference between the assignment operator and the equality operators.

Lol, made a typo and did assignment operator except for equality operator… xd haven’t noticed that, and that can be quite annoying. Anyway, thanks for the reply :slight_smile: