use javascript's Object.keys instead of array_keys
made the code compatible with jslint

also fixes #6, we were using i and j variables without declaring them
with "var".