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

Andrew Cauthorn
Andrew Cauthorn
6,257 Points

Questions answered always equals zero.

I basically followed along the video to complete this challenge, but I still can't get it to work. Any help is appreciated. :)

var questions = [
  ['MJ championships?', '6'],
  ['Lillard"s number?', '0'],
  ['Elliot Smith Albums Number?', '6'],

var correctAnswers = 0;
var question;
var answer;
var response;
var html;

function print(message) {

for (var i = 0; i < questions.length; i += 1) {
  question = questions[i][0];
  answer = questions[i][1];
  response = parseInt(prompt(question));
  if (response === answer) {
      correctAnswers += 1;

HTML = "you got " + correctAnswers + " question(s) right.";

2 Answers

Armin Kadic
Armin Kadic
13,229 Points

Looks like you missed a few small but important details. First detail is that you made the answers (numbers) in the "questions" variable to strings. Remove the quotes on the numbers, because otherwise the loop won't count it. Second one you wrote a comma (,) after your last array question-answer on line 4, remove it since there is no array following it. Third and last I believe is that you wrote on the last two lines "HTML" in caps lock while the variable name is "html", since javascript is case-sensitive, this isn't a good idea. If this helps you resolve your question, mark this answer as "best answer". :)

Good luck!

Andrew Cauthorn
Andrew Cauthorn
6,257 Points

Wow. I can't believe I missed those three things. Thanks for the assistance!