No reason to check for loop condition with additional IF statement
No reason to check for loop condition with additional IF statement

I also added collection length caching, pretty common in javascript.
521dimensions/amplitudejs