how to write better javascript