Hi, so from reading around the forum I’m supposed to return a function if there is more than one set of arguments passed, like in the example addTogether(2)(3)
I’m trying to take a look at this and understand what’s going on, but everything I do just returns ‘is not a function’. I don’t have working code, at the moment I’m just trying to access the second set or arguments, or gets arguments length. I don’t understand what’s going on or how to access the 3!?
This is a recursive function, the function is calling itself from inside the function. Don’t do that f you don’t know how to work with the recursiveness, and with a condition to stop it, you will just end with a stack overflow
Okay thanks but when I ran this code it returned the 5 which is what I thought it would do when I wrote it…
So just to check the logic, I thought at first these were two arguments being passed in different syntax, but actually (2) needs to be made into a function that can then take (3) as an argument?
Oh, you are right, you just used the same name for the function and its parameter. It can become incredibly confusing. Please avoid, you want to be sure what is what.
(2) is not a function by itself. When you write functionName(2) and that returns a function, you can write functionName(2)(3)