Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Correct answers are not counted.

I followed along with the video multiple times and keep running into the same problem. Even when I type the correct answers to the quiz, it always says I got "0 correct answers".

var array = [
  ['What is the color of the sky?', 'blue'],
  ['What is your name?', 'bob'],
  ['What day is it?', 'friday']
];

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

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


for (i = 0; i < array.length; i += 1) {
  question = array[i][0];
  answer = array[i][1];
  response = prompt(question);
  response = response.toLowerCase;
  if (response === answer) {
    correctAnswers += 1;
  }
}

html = "You got " + correctAnswers + " question(s) right.";
print(html);

1 Answer

Liv Larsen
Liv Larsen
1,799 Points

Hi Zach, ".toLowerCase" is a method, meaning you're missing the "()" at the end. Try this adding them like this: "response = response.toLowerCase();

It should solve your problem :)