Arguments Optional - need help

Arguments Optional - need help
0.0 0

#1

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);

Link to the challenge:


#2

This is because the addTogether you are calling at the end of the page is not a function. So make it look like this:

var addTogether = function addTogether(){
............

}

#3

It looks like your function has been set without an argument

function addTogether( ARGUMENT SHOULD GO HERE) {

so when you run

addTogether(2)(3);

its trying to add a value to arguments that you have not defined.


#4

I tried setting an argument before but it didnt solve anything


#5

This might help -https://www.youtube.com/watch?v=KhiNrf6RqxQ

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.