プログラムは、ページの下部に正解を追加していません。私はなぜクロムのプロンプトが正しく答えるとしても、キャップを付けても、条件付きのステートメントはそれらをquestionsRightに追加していないことはわかりません。var questions正しい答えが追加されていません
var quiz = [
['What is the capital of New York', 'Albany'],
['What is the Capital of California', 'Sacramento'],
['What is the capital of New Jersey', 'Trenton'],
['What is the capital of Virginia', 'Richmond']
];
var questionsRight = 0;
var questionsWrong = 0;
var questionsRightList = [];
var questionsWrongList = [];
/* Don't NEED to declare the following right away, but it's good practice to go ahead
and declare the variables you're going to use. Notice you don't need to assign any
default value to them */
var question;
var answer;
var response;
var html;
function print(message) {
document.write(message);
}
for(var i = 0; i < quiz.length; i++) {
// Get the first item from array[i] and set it as question
question = quiz[i][0];
// Get the second item from array[i] and set it as answer
answer = quiz[i][1];
// Get input from the user and set it to the response variable
response = prompt(question);
if (question === answer) {
//questionsRight is initially 0. If response === answer questionsRight = 0+1
questionsRight += 1;
}
// else {
// //questionsWrong is initially 0. If response === answer questionsWrong = 0+1
// questionsWrong += 1;
// }
}
html = "You got " + questionsRight + " question(s) right.";
print(html);
こんにちは答えを選択してください。 –