Actual problem with ending dates does not belong to timeouts (however, that's still a problem with them)
first - you created one inning
object while you need to create 10
so, move
var inning = new Object();
inside the first for
loop, this way you will create 10 inning objects instead of one.
second - you misused moment
library object
inning.start = beginning.moment.add("hours", (inningHours * x)); //WRONG
you just modified beginning.moment variable which is not what you trying to achieve!
In javascript, all objects are passed by references https://stackoverflow.com/a/16880456/870183
So, you must create new moment object and then modify it.
inning.start = moment(beginning.moment).add("hours", (inningHours * x)); //correct
third - timeout problem. For every timeout we need to create another function with another x variable
Closures was hard to understand for me, so keep trying. https://stackoverflow.com/a/111200/870183
Let's create a function which will return another function
function endInningFunc(x){
return function () {
endInning(x)
}
}
and then we will pass new function where x will be "locked" to its value to setTimeout
setTimeout(endInningFunc(x), timeTillEnd);
last thing, don't use global variables! http://www.webdevelopersnotes.com/tutorials/javascript/global_local_variables_scope_javascript.php3
for example, for (var x=0);
finally, the working example. http://jsfiddle.net/LmuX6/13/