i was learning in free code camp and i fell into a problem arguments[1]
result into undefined when the function gets called like this functionName(arg1) (arg2)
so for example arguments[1]
would result in undefined but using this solved it return (second) => addTogether(first, second);
and i don’t know how a function call in the function itself could have accessed something that even the arguments[1]
couldn’t access, can anyone explain
here is the full code if anyone is interested:
function addTogether() {
const [first, second] = arguments;
if (typeof(first) !== "number")
return undefined;
if (second === undefined)
return (second) => addTogether(first, second);
if (typeof(second) !== "number")
return undefined;
return first + second;
}