One line of javascript. What is this?

One line of javascript. What is this?
0.0 0

#1

Its one of the unit tests for the “Arguments Optional” challenge in the Front End Development Certification course. Pretty standard, the student writes the body of a function called by the unit test.

Last unit test function call looks like this:

addTogether(2)([3])

What is the second paren? Looks like a syntax error to me, but the interpreter doesnt mind. What am I missing?


#2

From the challenge: "addTogether(2) should return a function".

So let’s say you call this function with only one argument:

let sumTwoAnd = addTogether(2);

The value of sumTwoAnd is a function (addTogether is supposed to return a function when it receives only one argument). You can call this just like any other function like sumTwoAnd([3]), which will add 2 to [3].

That line of code is doing the same thing, only it’s not saving the result of the first function call.