In JavaScript, the code will still run if semicolons omitted. Unless multiple statements are put onto the same line.
Not sure if this is the problem, but it seems the minimum value your counter variable will ever be is 1.
Note that in JavaScript (and most programming languages), array indexes...