How to write an IF statement in JavaScript?