n
13

Vent: Spent a whole weekend debugging a single missing semicolon in JavaScript

So last Saturday I was working on this simple calculator project for my coding class. I spent like 6 hours tracking down why the add button kept returning NaN. I checked my functions, my variables, even rewrote half the code from scratch. Finally on Sunday night I realized I forgot a semicolon after a variable declaration at line 3. That one tiny thing broke everything. I felt so dumb but also kind of proud I figured it out. Has anyone else spent way too long on something this silly?
2 comments

Log in to join the discussion

Log In
2 Comments
john_singh
john_singh23d ago
Line 3 is always where the stupid stuff hides, I swear. One time in a group project for a CS101 class, I had a function that was supposed to pull data from a dropdown menu and it kept returning undefined. I spent like 8 hours over two days checking the DOM, the event listeners, even reinstalled jQuery. Finally my teammate looked at it and pointed out I had a typo in the variable name - I wrote "dropdwn" instead of "dropdown" at line 3 but then used the right name everywhere else. That was the moment I started naming my variables like "myDropdownThing" just to be absolutely sure. The dumbest thing is that the autocomplete in my editor was highlighting the misspelled one and I still didn't catch it.
10
jesse_nguyen
Feel that pain hard man. I spent like 4 hours once chasing a bug in a loop that turned out to be a comma instead of a semicolon in a for statement. What helped me after that was getting a good linter setup for my code editor. ESLint catches those missing semicolons before you even run the code most of the time. Also if you're using VS Code there's an extension called Error Lens that shows errors right in the editor line instead of hiding them in the console. Saves me so much time now I can't even count.
2