I know WHY this doesn't work, but can't find the correct way of doing it.
I'm trying to build an object using a loop. The Object builds fine, but when I try to use the callback, it alerts "2" for each person, I'd like it to alert the position in the array.
var playerArr = ["steve", "paul", "bob"];
var myAutomatedObj = {};
for (var i=0; i<playerArr.length; i++){
    var objName = playerArr[i];
    myAutomatedObj[objName] = {};
    myAutomatedObj[objName]["callback"] = function(){
        alert(i);
    }
}
//returns incorrect alert
myAutomatedObj.steve.callback();
 
    