Your code will definitely become longer and more complex as you try to solve complex problems with Javascript. But there is an easy way to fix this. No need to giving up on JS code yet!