JavaScript Asynchronous Programming with JavaScript Asynchronous JavaScript with Callbacks Callbacks Review

italiandadx2
italiandadx2
2,885 Points

I don't understand why (sum) is used.

The function add is asking for 3 arguments one of those being a function. I understand that much... What I do not get is when the add function is invoked the function being passed as the third argument has an argument of sum...?

Reggie Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Reggie Williams
Treehouse Teacher

Hey italiandadx2 ! function(sum) is the third argument. The function has the argument of sum because it's anonymous and doesn't have another definition. Because we see sum as an argument of the function we know that the value passed in will be passed as well in place of the word sum inside the function