I've debugged a lot of code over the years, most of it my own.
First learn to code to the standard, then learn when to break the rules. Every language has a beauty, embrace it. There are tools that will help along this path... finding the right editor or IDE is important for any language, for JavaScript I've found the JSLint -> JSHint -> ESLint evolution, followed by Yeoman's Grunt to be really instructive and useful.