Not sure what you mean by "running this code using Sublime Text", as Sublime Text is a text editor. You run that code in a web browser!
Sublime Text is a great text editor, and it's the one that I use myself. If you use it properly, it would have shown you these errors.
- make sure you have not somehow disabled syntax highlighting, and make sure your files have appropriate extensions (e.g. .html for HTML, .js for Javascript). Syntax highlighting will make it easier to read your code, by using different colors for different bits of syntax. (e.g. variables, keywords, etc. etc.) It will also flag simple syntax errors.
- Make it easier for ST to show you errors by keeping HTML CSS, and JS in separate files - don't mix everything up in one file! If you keep them separate, ST can show you a lot of problems before you even try your code in a browser!
- You can do more through checking of JS by installing a Sublime Text lint package. I lint every JS file every time it is loaded, and every time it is saved!
- There are many additional ST packages you can install that will help find problems. BracketHighligher is a good one for starters. There are many choices for linting: I use SublimeLinter. You load additional packages for each language you want to lint.
- In case you are using ST2, realize that ST3 (though in perpetual beta) is much better, and, really, hardly anybody uses ST2 any more. All the important packages have already been rewritten for ST3.
----
I put your example into ST. It shows the first error. Do you notice the question mark in the left-hand column of line 6? It means there is an error parsing the HTML.
If you had kept your HTML, CSS, and JS in separate files, it would have shown you more.