I keep getting errors! What's one easy way to fix them?


#1

Question

I keep getting errors! What’s one easy way to fix them?

Answer

To first fix an error we need to know what’s causing them! When you get an error look at the error message in the console. It’ll first tell you the file in which the error is coming from and the line number followed by the line itself. Example:
/PATH/TO/DIRECTORY/file.js:7 var line = Gives error
Here we have the path to the directory of the file, the filename (file.js), and what line number is causing the error (7). It then shows us the line that caused the error and is then followed by the error message:
SyntaxError: Unexpected identifier at ... ...
The error message is telling me Javascript has no idea what’s going on at this line, so we take a look and try and spot what’s wrong with the line. When we take a look we see we forgot to add quotes around Gives error. Adding the quotes fixes the problem and the error.