I am struggling with a Javascript question for some time now and I was not able to find an explanation on the web. I guess it is because I do not enter the right keywords wh
Since JavaScript has function scope, you can use a function to store the value of n like so:
var addn = (function(n) { return function(x) { n += x; return n; } }(2); addn(3) // 5 addn(3) // 8