There are a plethora of code style guides online to help you write better code. But many of them fail to give you the context to make your own decisions. This video shows what to watch for when reading style guides. And if you have your own style guide, how to make it reasonable.
And, if you really want help with JavaScript, I have a course where I apply these principles to help you write JavaScript well: On writing JavaScript well