Arguments Optional 1

Tell us what’s happening: Hi everyone. Could you help me with the code below, please.

addTogether(2, 3) should return 5. ???

Your code so far


function addTogether() {
  let args = new Array(arguments.length);

  for (let i =0; i < args.length; ++i){
    args[i] = arguments[i];

    if (args.length == 2){
      if(typeof args[0] !== 'number' || typeof args[1] !== 'number') {
        return undefined;
      }
       return args[0] + args[1];
        }
        if (args.length == 1) {
          let a = args[0];
          if(typeof a !== 'number'){
            return undefined;
          } else{
            return function(b){
              if (typeof b !== 'number'){
                return undefined;
              }
           
              return a + b;
            }
          }
        }
  }
  
}

addTogether(2,3);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15.

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