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

Janet Herrera
Janet Herrera
1,286 Points

"Cannot set properties of null (setting 'innerHTML')" in Random Array Index Project

I am working on the "Random Array Index" Project and have completed most steps to the best of my ability. I am stuck on the step #6 of the script.js file (Set the innerHTML of the scoreOneElement and scoreTwoElement variables above equal to the dice roll variables you just created).

My code is here: https://w.trhou.se/bki9fjn63z

When I run the code, I get an error message in the console: Uncaught TypeError: Cannot set properties of null (setting 'innerHTML') at HTMLInputElement.<anonymous>

The error code is line 53 of the script.js file. I have tried these two variations of the code on line 53 with the same results:

document.querySelector('main').innerHTML = score1; document.querySelector('main').innerHTML = scoreOneElement;

Any help would be greatly appreciated! Thank you

1 Answer

Janet Herrera
Janet Herrera
1,286 Points

Hello, I found one solution myself. I was not referring to "#score-1" If there are any other mistakes or other areas of improvement, please let me know! :)