L
25

Finally figured out console.log debugging in JavaScript lol

I've been learning JavaScript for about 2 months now and kept getting stuck on why my loops weren't working. My code looked fine to me but the output was all wrong. I tried reading tutorials and watching videos but nothing clicked. Then last night I just started throwing console.log statements everywhere in my code to see what values my variables actually had at each step. Turns out I was accidentally resetting a counter inside the loop without realizing it. I fixed it in like 5 minutes after that. Has anyone else had those moments where the simplest trick saves you hours of staring at the screen?
2 comments

Log in to join the discussion

Log In
2 Comments
victor_carr54
So were you checking each iteration or just dumping the whole loop result at the end?
5
mia_anderson
I used to think console.log was a crutch and real devs used debuggers but now I just dump everything into the console and it saves me every single time.
3