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 trial

JavaScript Breaking on Events and Basic Stepping

Greg Schudel
Greg Schudel
4,090 Points

getting error in console

I am having trouble fixing the error in the browser console directly. I typed listItem = checkbox.parentNode.parentNode in the console tab in the dev tools and got the following error:

Uncaught ReferenceError: checkbox is not defined
    at <anonymous>:1:1

what am I doing wrong?

2 Answers

A R
A R
12,834 Points

I had a similar problem. It came from entering 'listItem = checkbox.parentNode.parentNode;' too early; if you haven't reached line 69 in the code I don't think it will work.

Steven Parker
Steven Parker
231,248 Points

That's a good example for my original answer. You can't use "checkbox" as a reference until it has been defined itself.

Steven Parker
Steven Parker
231,248 Points

The error message would seem to indicate that you have not defined anything named "checkbox", or perhaps some syntax issue is preventing it from working.

To facilitate an analysis and make a more specific answer possible, show the complete code. Or better yet, make a snapshot of your workspace and post the link to it here.

Greg Schudel
Greg Schudel
4,090 Points

I figured out what I was doing wrong, I was using dev tools and I was swiveling from the "sources" tab to the "console" tab. Good to hear from you again Steven (err, hmmm, Peter! lol) Parker :)

I made the mistake of expecting that my change in the console would edit the code in the sources directly. It did not change the code but it did change the results (which were the desired results). All set here. thanks.