JavaScript: fix handling of various missing semicolons in loops