V
3

Shoutout to the guy who told me to use print statements

Spent 3 hours debugging a loop last Tuesday. Old timer at the coffee shop said to just print each variable. Found the bug in 10 minutes. Anyone else resistant to the simple stuff at first?
3 comments

Log in to join the discussion

Log In
3 Comments
jenny198
jenny1985h ago
Oh man, I have BEEN there. Did the same thing last week actually. I was overcomplicating a filter function and had like 15 nested conditions. Spent two hours writing comments and trying to trace logic in my head. Finally just threw a console.log in there and saw the variable was undefined like three lines before I thought it was set. Felt like the biggest fool ever. Print statements are the real MVP.
8
amyh12
amyh124h agoMost Upvoted
Wait, @mileslane... isn't console.log technically a print statement though?
8
mileslane
mileslane4h ago
Tried to debug a recursive function by staring at it for an hour last month. @jenny198 you're right about the undefined thing, that's always the sneaky one. Print statements save so much time but we all think we're too smart for them at first.
1