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 User Interface Code

My questions won't appear because I am getting an error that says .innerHTML can't be null...

I am so frustrated!!! I have been through my code and compared it with Andrew's countless times. I changed mine to match his but I am still getting this error. I don't know what is wrong. When I preview, the question appears but the choices do not. https://w.trhou.se/8lop040ssd This is a snap shot of my code.

4 Answers

Jason Desiderio
Jason Desiderio
21,811 Points

Marlinda Davis - it seems most of your problems are in the quiz_ui.js file with one more being in the question.js file. There are a few commas that shouldn't be there and it is messing with the ID selection in the populateIdWithHTML function.

On line 18 and line 19, there shouldn't be a comma after "choice" or "guess". It should look like this:

for(var i = 0; i < choices.length; i++) {
      this.populateIdWithHTML("choice" + i, choices[i]);
      this.guessHandler("guess" + i, choices[i]);
   }

Next, on line 41, there shouldn't be a comma after "Question ". It should look like this:

this.populateIdWithHTML("progress", "Question " + currentQuestionNumber + " of " + quiz.questions.length);

Lastly, on line 8 of question.js, there shouldn't be an 's' on the end of this.answer. It should look like this:

return this.answer === choice;

Hey, i found the issue for the questions showing up: there's just a bad comma in both of these argument lists:

for(var i = 0; i < choices.length; i++) {
      this.populateIdWithHTML("choice", + i, choices[i]);
      this.guessHandler("guess", + i, choices[i]);
   }

it should just be:

for(var i = 0; i < choices.length; i++) {
      this.populateIdWithHTML("choice" + i, choices[i]);
      this.guessHandler("guess" + i, choices[i]);
   }

Now it should work!

ONE of your problems is that you have a comma between your 2 variables that are supposed to be concatenated on lines 18, and 19 of quiz_ui.js. It those lines should be as follows:

this.populateIdWithHTML("choice" + i, choices[i]);  // because the html ids you are after are 'choice0' and 'choice1'
this.guessHandler("guess" + i, choices[i]); 

You have another problem as well at the bottom with your displayProgress function, and how you are calling populateIdWithHTML. You can see that the populateIdWithHTML function accepts 2 parameters, yet you are giving it 3 (each separated by a comma). I'll let you figure this one out, and if you still have trouble with it you can post again.

Thank you both so much! It works now. I really appreciate the help.