[solved ] Arguments Optional Help

[solved ] Arguments Optional Help
0

#1

Hi guys. I’m really close on this one but this last part I’m getting stuck on. When i pass in the arguments as below, I think it’s converting the “3” into a number, which obviously I don’t want it to do as I want it to return undefined. How can i stop this from happening? Thanks

function addTogether(a,b) {
  
  var hold = 0;
  
  if (typeof(a) === "number") {
    if (arguments.length === 1) {
      return function secondOrderFunc(b) {
        if (typeof(b) === "number")
          return a + b;
        else {
          return undefined;
        }
    };
    
    } else if (arguments.length === 2) {
        return a + b; 
    }

  } else {
    return undefined;
  }
  
}

addTogether(2, "3");

#2

It looks like the problem is there, maybe you could have an && to make sure a string doesn’t pass?


#3

Ah of course! How silly of me, got it now thanks :slight_smile: