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

Quiz Application Console errors

I get these errors when trying to run The quiz Application app from Object-Orientated JavaScript Track.

Uncaught SyntaxError: Unterminated template literal quiz_ui.js:25 Uncaught SyntaxError: Unexpected token this app.js:8 Uncaught ReferenceError: Quiz is not defined app.js:8

quiz.js.......

function Quiz(questions) {
  this.score = 0;
  this.questions = questions;
  this.currentQuestionIndex = 0;
}

Quiz.prototype.guess = function(answer) {
 if(this.getCurrentQuestion().isCorrectAnswer(answer)) {
      this.score++;
    }
  ` this.currentQuestionIndex++;
};

Quiz.prototype.getCurrentQuestion = function() {
    return this.questions[this.currentQuestionIndex];
};

Quiz.prototype.hasEnded = function() {
    return this.currentQuestionIndex >= this.questions.length;
};

quiz_ui.js...

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 += "<h1> Your Score is: " + quiz.score + "</h2>";
    ``  this.populateIdWidthHTML("quiz", gameOverHTML);
    },

    populateIdWidthHTML: function(id, text) {
        var element = document.getElementById(id);
        element.innerHTML = text;
    },
    guessHandler: function(id, guess) {
        var button = document.getElementById(id);
        button.onclick = function(){
          quix.guess(guess);
          QuizUI.displayNext();
      }
    },

    displayProgress: function() {
        var currentQuestionNumber = quiz.currentQuestionIndex + 1;
        this.populateIdWidthHTML("progress","Question " + currentQuestionNumber + " of " + quiz.questions.length);
    }
};

app.js.....

var questions = [
    new Question("Who was the first President of the United States?", [ "George Washington", "Thomas Jefferson" ], "George Washington"),
    new Question("What is the answer to the Ultimate Question of Life, the Universe, and Everything?", ["Pi", "42"], "42"),
];

var quiz = new Quiz (questions);

QuizUI.displayNext();