Given the Python example in the article:
def f(n):
num = 0
while num < n:
yield num
num += 1
what's wrong with: function f(n) {
var num = 0;
return function () {
if (num < n) {
return num++;
}
}
}