I'm not sure why I'm getting an error on the following snippet (adapted from JavaScript closure inside loops – simple practical example):
var funcs = {};
for (var i = 0; i < 3; i++) {          // let's create 3 functions
    funcs[i] = (function(n) {            // and store them in funcs
        console.log("My value: " + n); // each should log its value.
    })(i);
}
for (var j = 0; j < 3; j++) {
    funcs[j]();                        // and now let's run each one to see
}
It seems like this should run ok; I know this is just something I don't fully get.
Here is the errror I get:

thx for any help
 
     
    