H
17

Spent 3 hours fighting a missing semicolon in my JavaScript

Was working on a simple to-do list app at my kitchen table last Tuesday. Everything looked fine. Code was clean. Then I ran it and nothing worked. Console showed zero errors. I checked every line three times. Finally I saw it. A semicolon was missing inside my for loop inside an if statement. Not at the end of a line where you expect it but right in the middle of a condition. It crashed the whole loop silently. I felt dumb but also kind of mad that such a tiny thing could break everything. Has anyone else wasted hours on a single character that was hiding in plain sight?
2 comments

Log in to join the discussion

Log In
2 Comments
holly_gonzalez61
Missing semicolons are one of those things that feel like a rite of passage, you know? I actually think the silent failure is way more frustrating than an error message screaming at you. At least with an error you have a starting point, but that zero feedback thing is just cruel. I've definitely spent an embarrassing amount of time staring at a single line wondering why my brain couldn't just see it the first time. It's annoying but it also kinda teaches you to slow down and read code like it's a puzzle instead of just skimming it.
2
tylerw72
tylerw7221d ago
Oh man, you totally nailed it. I spent three hours once hunting down a missing semicolon in a JavaScript file and finally gave up and deleted the whole function and rewrote it from scratch (only to realize the original one was fine and I'd left out a semicolon in the line before a comment). The silent failure is absolutely the worst part because your brain just fills in the blank and thinks everything is fine. It's like trying to find a single missing puzzle piece in a carpet of the same color, you know? I've started reading my code out loud now just to catch those dumb things, but it still happens way too often.
10