Fix semicolons.
Avoid for loops.
Don't try to declare a var called "undefined"
Use separate var statements.