JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 1 Solution

Why doesn't a prompt pop up? (pls check out my code) 😭

function print(message) {
  document.write(message);
}

var correct = 0;
var answer;

var questionList = [
  ["How many countries are there?", 195],
  ["How many planets are there?", 8],
  ["When you call a function, the pieces of information being passed to that function are called what?", "arguments"]
];

for (var i = 0, i < questionList.length, i++) {
  answer = prompt(questionList[i][0]);
  if (answer == questionList[i][1]) {
    correct += 1;
  }

}

print("You've answered " + correct + " questions.");

(There're probably 99 problems with my code but please bear with me 😂😭😭)

1 Answer

Steven Parker
Steven Parker
180,120 Points

The clauses of a "for" loop must be separated by semicolons:

for (var i = 0, i < questionList.length, i++) {  // original
for (var i = 0; i < questionList.length; i++) {  // corrected

😉

oh that's right 😂...thank you again Steven you're a lifesaver 🙏😭😭