Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Andrew Cauthorn
Andrew Cauthorn
8,581 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

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
8,581 Points

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