hi, i tried to figure out my own version of this problem and my intention was to check, as first thing to do, if either the arguments were NaN, after that branching the problem for the 2 arguments or one argument case. But it is not working…can someone explain me why?
this is the code
function addTogether() {
if (typeof arguments[0] !== "number"
||typeof arguments[1] !== "number" ) {
return undefined;
} else if (arguments.length === 2) {
return arguments[0]+arguments[1];
} else if (arguments.length === 1) {
let first = arguments[0];
function addSecond(second) {
// Check if the new argument is a number
if (typeof second ==="number") {
return first + second;
} else {
return undefined;
}
}
return addSecond;
}
}