Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohn Barhorst
9,648 PointsDOMContentLoaded Event listener prevents accessing variables in the console?
I hadn't bothered to change the HTML and app back from earlier in the project. In trying to work out some things for these challenges, I was playing in the console and found that all my variables came back as undefined. I'm not sure why I thought to change back the event listener and the script tag location, but now that I have done that I can properly access my variables.
Anyone want to shed some light on this? Everything about the app was otherwise working properly, so I'd assume that meant the DOM was fully loaded, and thus the variables should exist. Is there some scope limitation to the event listeners that prevent it from working in console? Or some sort of extra step we need to work around if, out in the wild, we have to work under a situation like this?
Thanks for your time!
Steven Parker
231,269 PointsSteven Parker
231,269 PointsTo facilitate analysis of your issue, please show your code (properly formatted with Markdown) here. Or, you can make a snapshot of your workspace and post the link to it here.