T
5

TIL a missing semicolon cost me 4 hours of debugging

Was working on a simple JavaScript function for my personal site last weekend. Just wanted to loop through an array and display some items. Kept getting an error that made no sense. Checked my syntax like 15 times. Finally asked a friend to look at it and he spotted a missing semicolon on the line before the loop. Four hours for one tiny missing character. Has anyone else spent way too long on something this small?
2 comments

Log in to join the discussion

Log In
2 Comments
grant.nina
grant.nina1mo ago
...and what's worse is that you probably looked right at that line a dozen times and your brain just filled in the missing semicolon for you... My advice? Start using a linter. I know it feels like overkill for a little personal site but it would have caught that in half a second and saved you all that frustration. I actually set up ESLint for my own tiny projects after I spent a whole evening chasing a bracket that was one space off. It's annoying to set up at first but trust me, it pays off big time. Also, when you're really stuck, try reading your code out loud line by line. Sounds silly but it forces your brain to actually process each character instead of guessing.
7
margaret99
margaret991mo ago
Four hours for one semicolon? Oof, I've been there.
5