Normalize JavaScript to a consistent style

I don't really care about the specifics of style (to an extent!), but I do prefer consistency. There's also some lint errors that got fixed along the way.