even though i saw other solutions that were similar to mine and were working, mine keeps throwing an error:
TypeError: addTogether(…) is not a function
would be great if any of you could point out my mistakes
My code
function addTogether() {
var a = arguments[0];
var b = arguments[1];
if(typeof a !== "number" || typeof b !== "number"){
return undefined;
}
else if(arguments.length === 2){
return a + b;
}
else if (arguments.length === 1 && typeof a == "number"){
return function(c){
return a + c;
};
}
}
addTogether(2)(3);
If not https://watchandcode.com/ has an excellent section early on that really helps explain it. He uses a sayHiTo for an example and it helped me, after I was stuck on this forever.