the problem is that the variable i, within each of the inside anonymous functions, is bound to the same variable outside of the function.
we could just do this
function createfunc(k) { return function(i) { return i+k; }; }
function createArrayOfFunctions(y){ for (var i = 0; i < j; i++) { var arr = []; arr[i] = createfunc(i); } }