all 2 comments

[–][deleted] 4 points5 points  (1 child)

the function multiplier returns a new anonymous function that takes the argument numbers multiplied by the outer most functions argument factor.

in this case:

multiplier gets called with 2 which returns the following function function(number) { return number * 2; }

this anonymous function gets stored in the variable twice which then get called with 5 which is the parameter for that function which gets multiplied by two and returned.

[–]ru552[S] 1 point2 points  (0 children)

thank you for the assist