This comment falls under the "nitpick" category, but can you add a space between if and the parenthesis?
There's a good JavaScript styleguide by AirBnb that I like to follow:
https://github.com/airbnb/javascript