Modifying javascript to use goog.array.forEach() where needed