Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript (2015) Practice Project Quiz Prototype

Cannot set property 'innerHTML' of null

I keep getting this error message in Dev tools in Google Chrome: Uncaught TypeError: Cannot set property 'innerHTML' of null I've looked over my code and I can't find a problem!

Here's a snapshot of my code... https://w.trhou.se/4566eakx5x

1 Answer

Daniel Jenkins
Daniel Jenkins
17,714 Points

Hi David, it looks to me as though you have too many options for the question answers for your html. You define three options for each question but the html only defines two 'p' elements for your choices, so when your loop gets to 'choice2' it fails as there is no element with id 'choice2'. The getElementById call is returning 'null' because it can't find anything with the given id.

Hope that helps.