Intermediate Algorithm Scripting - Arguments Optional

Hello guys. I am stuck at last test with this problem and I didn’t find anything relevant on this. At the pass " addTogether(5, undefined) should return undefined " I get // [ Function: add]. I understand why but I don’t know how to solve it. I would appreciate if you will help me, thanks.

Your code so far

function addTogether(param1, param2) {

  if(param2 !== undefined && typeof(param1) === 'number' && typeof(param2) === 'number') {
    return param1 + param2;
  }
  else if (param2 === undefined && typeof(param1) === 'number') {
       return function add(param2) { 
         if(typeof(param2) === 'number') {
             return param1+param2;
          }
     }
  }
  else {
  return undefined;
  }
}
console.log(addTogether(5, undefined));

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Arguments Optional

Link to the challenge:

You should read about this piece of Javascript