Hey, can someone tell me what is wrong with this code please?
It doesn’t pass the test because “addTogether(2)([3]) should return undefined.”
It does return undefined, doesn’t it?
function addTogether() {
if(arguments[1]){
if(typeof arguments[1] !== 'number'){
return undefined;
} return arguments[0] + arguments[1];
}
if(typeof arguments[0] == 'number'){
let a = arguments[0];
return function(num){
return a + num;
}
}
}
console.log(addTogether(2,[3])); //returns undefined
Challenge: Arguments Optional
Link to the challenge: