Tell us what’s happening:
Hello everyone, I can’t figure out why my code gives me an error message :
“TypeError: addTogether(…) is not a function”
Can someone help me ?
Thanks in advance !
Your code so far
function addTogether() {
for (let i = 0; i < arguments.length; i++) {
if (typeof(arguments[i]) !== "number") {
return undefined;
}
}
if (!arguments.length < 2) {
return arguments[0] + arguments[1];
} else {
let arg1 = arguments[0]
return (arg2) => {
if (typeof(arg2) !== "number") {
return undefined;
} else {
return arg1 + arg2;
}
}
}
}
addTogether(2)(3);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
.
Challenge: Arguments Optional
Link to the challenge: