if statement for js, and fix multiple comma issue