Improve JavaScript `for` snippets

While poking around the JavaScript snippets, I noticed that the `for` loop snippets could use a little tweaking. This pull request improves them in a few small ways.