22
Finally figured out why my code kept breaking - turns out it was semicolons
I used to just copy code from tutorials and hope it worked. But last week I was stuck for 3 hours on a simple loop because I kept missing semicolons in JavaScript. My friend pointed out that I was writing 'let x = 5' without the semicolon at the end, and once I added them all, everything ran. Has anyone else had a tiny syntax thing take forever to figure out?
3 comments
Log in to join the discussion
Log In3 Comments
walker.julia20d ago
ikr I spent 2 hours once cuz of one missing semicolon in a for loop
4
stella_scott9620d ago
God the "copy from tutorials and hope it worked" part hit me hard lol. I literally did that for months until I had a similar thing happen but with curly braces in some CSS I was trying to write. I spent a whole afternoon staring at the screen and it turned out I was missing one stupid closing brace on a media query. What finally clicked for me was using a code linter that highlights those tiny mistakes in real time. It saved me so much headache because now I can see the problem right as I type instead of hunting for it later.
3
blair_chen8120d ago
@stella_scott96 the linter thing is huge, I started using one in VS Code and it catches my missing semicolons before I even save the file. But the real game changer for me was switching to TypeScript because the compiler yells at you for that kind of stuff way harder than plain JS does. It forced me to be way more careful about syntax and now I barely make those dumb mistakes anymore.
2