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.

Martina Vonkomerova
7,790 PointsUI is not rendering
My code for QuizUI is:
var QuizUI= function(){
displayNext:function(){
if(quiz.hasEnded()){
this.displayScore();
}
else{
this.displayQuestion();
this.displayChoices();
this.displayProgress();
}
}
displayQuestion: function(){
this.propulateIdWithHtml("question", quiz.current().text);
}
displayChoices:function(){
var choices= quiz.current.choice;
for(var i=0;i<choices.length;i++){
this.propulateIdWithHtml("choice"+i, choices[i]);
this.guessHandler("guess",choices[i]);
}
}
displayScore:function(){
var gameover="<h1> Game Over <h1>";
gameover+= "<h2> Your score is:"+quiz.score+"</h2>";i
this.propulateIdWithHtml("quiz",gameover);
}
populateIdWithHtml: function(id,text){
var element = document.getElementById(id);
element.innerHTML= text;
}
displayProgress:function(){
var currentindex = quiz.current +1 ;
this.propulateIdWithHtml("progress", "Question"+currentindex+ "of" + quiz.questions.length);
}
guessHandler:function(id,guess){
var element = document.getElementById(id);
element.onclick= function(){
quiz.guess=guess;
QuizUI.displayNext();
}
}
}
4 Answers

Ace Motanya
31,756 Pointsvar QuizUI = {
displayNext: function () {
if (quiz.hasEnded()) {
this.displayScore();
} else {
this.displayQuestion();
this.displayChoices();
this.displayProgress();
}
},
displayQuestion: function() {
this.populateIdWithHTML("question", quiz.getCurrentQuestion().text);
},
displayChoices: function() {
var choices = quiz.getCurrentQuestion().choices;
for(var i = 0; i < choices.length; i++) {
this.populateIdWithHTML("choice" + i, choices[i]);
this.guessHandler('guess' + i, choices[i]);
}
},
displayScore: function() {
var gameOverHTML = "<h1>Game Over</h1>";
gameOverHTML += "<h2> Your score is: " + quiz.score + "</h2>";
this.populateIdWithHTML("quiz", gameOverHTML);
},
populateIdWithHTML: function(id, text) {
var element = document.getElementById(id);
element.innerHTML = text;
},
guessHandler: function(id, guess) {
var button = document.getElementById(id);
button.onclick = function() {
quiz.guess(guess)
QuizUI.displayNext();
}
},
displayProgress: function() {
var currentQuestionNumber = quiz.currentQuestionIndex + 1;
this.populateIdWithHTML("progress", "Question " + currentQuestionNumber + " of " + quiz.questions.length);
}
}

Ace Motanya
31,756 Pointsits hard to read your code but umm try this and maybe you can compare and contrast and figure out where you went wrong
```var QuizUI = { displayNext: function () { if (quiz.hasEnded()) { this.displayScore(); } else { this.displayQuestion(); this.displayChoices(); this.displayProgress(); } }, displayQuestion: function() { this.populateIdWithHTML("question", quiz.getCurrentQuestion().text); }, displayChoices: function() { var choices = quiz.getCurrentQuestion().choices;
for(var i = 0; i < choices.length; i++) {
this.populateIdWithHTML("choice" + i, choices[i]);
this.guessHandler('guess' + i, choices[i]);
}
}, displayScore: function() { var gameOverHTML = "<h1>Game Over</h1>"; gameOverHTML += "<h2> Your score is: " + quiz.score + "</h2>"; this.populateIdWithHTML("quiz", gameOverHTML); },
populateIdWithHTML: function(id, text) { var element = document.getElementById(id); element.innerHTML = text; }, guessHandler: function(id, guess) { var button = document.getElementById(id); button.onclick = function() { quiz.guess(guess) QuizUI.displayNext(); } },
displayProgress: function() { var currentQuestionNumber = quiz.currentQuestionIndex + 1; this.populateIdWithHTML("progress", "Question " + currentQuestionNumber + " of " + quiz.questions.length); } }```

Martina Vonkomerova
7,790 PointsThank your for your help, but it hasn't worked out yet.

christopherkaczenski
16,079 PointsNotice that the syntax for adding methods to object literals is slightly different than when using constructor functions.
QuizUI is an object literal, so there needs to be a comma after every method. Also, you do not need the "function()" keyword when defining an object literal with methods such as QuizUI.
Ace's code should work, but try clearing your cache.