I'm trying to run multiple timers given a variable list of items. The code looks something like this:
var list = Array(...);
for(var x in list){
setInterval(function(){
list[x] += 10;
console.log(x + "=>" + list[x] + "\n");
}, 5 * 1000);
}
The problem with the above code is that the only value being updated is the item at the end of the list, multiplied by the number of items in the list.
Can anyone offer a solution and some explanation so I know why it's behaving this way?