The counter in your for loop appears incorrect (or we're missing some code). Here's a working Fiddle.
This code:
//Where is counter[0] initialized?
for (i ; i < counter[0].value; i++)
Should be replaced with:
var timeTempCount = 5; //I'm not sure where you're getting this value so I set it.
for (var i = 0; i <= timeTempCount; i++)