B
17

Warning: I spent 6 hours debugging a missing semicolon in JavaScript

I just started learning JavaScript two weeks ago and I ran into this error that made NO sense. My code looked fine but the console kept throwing an error about an unexpected token. After 6 HOURS of googling and staring at my screen, I found it was a single missing semicolon on line 3. I read online that 80% of beginner bugs are syntax errors like this, but I didn't believe it until now. Has anyone else spent way too long on something this simple? How do you catch these things faster?
2 comments

Log in to join the discussion

Log In
2 Comments
wendyg43
wendyg4315d ago
Yeah have you tried using a linter? I started using ESLint a few months ago and it catches missing semicolons right when I type them. Saves me from this exact headache. Also I got into the habit of putting semicolons before every opening bracket in my code, just muscle memory now.
9
murray.drew
Man a linter would have saved your life there. I've done that exact thing with Python once, spent 4 hours on a missing colon after a function definition. Now I just run the code after every few lines so I catch stuff immediately instead of writing a whole page and then wondering why nothing works.
4