所以我不断收到script.js:64 Uncaught SyntaxError: Invalid or unexpected token
错误,即使我的代码中的第64行没有任何内容,但在Chrome的源代码选项卡中,在我的javascript文件中,我看到该行上的拼写错误
这是什么问题?我的代码:
function Question (theQuestion, theChoices, theCorrectAnswer) {
this.question = theQuestion;
this.choices = theChoices;
this.correctAnswer = theCorrectAnswer;
this.UserAnswer = "";
var newDate = new Date();
QUIZ_CREATED_DATE = newDate.toLocaleDateString();
this.getQuizDate = function () {
return QUIZ_CREATED_DATE;
};
console.log("Quiz Created On: " + this.getQuizDate());
}
Question.prototype.getCorrectAnswer = function () {
return this.correctAnswer;
}
Question.prototype.getUserAnswer = function () {
return this.UserAnswer;
}
Question.prototype.displayQuestion = function () {
var questionToDisplay = "<div class='question'>" + this.question + "</div><ul>";
choiceCounter = 0;
this.choices.forEach(function (eachChoice) {
questionToDisplay += '<li><input type="radio" name="choice" value="' + choiceCounter + '">' + eachChoice + '</li>';
choiceCounter++;
});
questionToDisplay += "</ul>";
console.log (questionToDisplay);
}
function MultipleChoiceQuestion (theQuestion, theChoices, theCorrectAnswer) {
Question.call(this, theQuestion, theChoices, theCorrectAnswer);
inheritPrototype(MultipleChoiceQuestion, Question);
}
allQuestions.forEach(function (eachQuestion) {
eachQuestion.displayQuestion();
});
clickBtn();
我尝试刷新缓存,但没有帮助。