I have a simple question here. Here is the code below
var num = 0;
var increment = function() {
return function() { num++; };
};
increment();
increment();
However, when I tried to run it, it errors with undefined is not a function. How come? Isn't increment clearly a function?
Also, when I wrote typeof increment, it returns undefined.
When increment() is called twice, it should modify num, and become 2.
var increment = function() { num++; }?increment()