A JS code review

I did a code review for a friend about a little piece of code and something worth of posting came out of there.

Here it is, first, the code he passed us, and after that, my answer.

It is a mix of idiomatic/readable/my-taste javascript advice. Comments welcome.