The easiest way to explain the code is to fill in the values during each call.
The function plusGenerator
is a function that takes an offset
and then returns another function that returns the result of adding offset
to another number. When you call plusGenerator(2)
, the function that is returned looks like:
var addTwo = function(x) { return x + 2; };
You then call addTwo(15)
which returns 17
.
1
solved Javascript Code explaination [closed]