Fix misspelling
Use different var i, max in each for loop
Add missing spaces; remove extra spaces
Add missing semicolons
Add missing var keyword
Add braces around if statement for clarity
One line between each function()
Remove stray whitespace
Add/remove spacing for readability and consistency

Add
  after : { () ,
  around =
  before } (

Remove
  after (
  before : )
  between function()
Indent consistently four spaces
Make punctuation consistent

- Remove sentence punctuation from comments.
- Add periods to `warn()` statements.
- Change to single quotes in comments.
Wrap all ternary operators in () for clarity
Wrap all typeof arguments in () for clarity and consistency