Refactor 'for each ...' into just for loops.

The 'for each' statement is not part of the ECMAScript standard, as such it's
not supported by all major javascript engines (such as Google's V8).  It's also
been deprecated to discourage it's use.  See
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for_each...in
for more information.

This patch refactors its usage into normal javascript for loops.
Merge pull request #182 from slagle/dev-slagle-compliance-js

Refactor 'for each ...' into standard for loop