F
24

Debugging my first app and variable scope is throwing me off

Can someone explain why my functions aren't accessing the variables I set outside them?
4 comments

Log in to join the discussion

Log In
4 Comments
vera29
vera291mo agoMost Upvoted
Ugh, global scope gets everyone at first.
8
janag43
janag431mo ago
Global scope is the worst. Caused me so many issues. Took ages to figure it out.
4
vera29
vera291mo agoMost Upvoted
My first big JavaScript project had like five variables with the same name. Total mess. Took me a whole weekend to fix all the weird bugs it caused. I still get nervous using var instead of let or const. It's one of those lessons you only learn the hard way.
6
the_laura
the_laura14d ago
Remember getting so lost in scope issues I almost gave up coding. I had a variable that kept changing when I didn't want it to, and it was all because I didn't understand closures. It really is a universal rite of passage.
6