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.

Solace Enwere
15,102 PointsCan someone please tell me why the correctAnswers count is not working in this code??
var quizList = [
['What is a programming language that is also a snake?', 'Python'],
['Who is the president of France?', 'Emmanuel Macron'],
['Which progeamming language is also a gem?', 'Ruby'],
['Which progamming language I\'m I learning right now?', 'JavaScript']
];
var correctAnswers = 0;
var ask;
function print(message) {
document.write(message);
}
function answerQuiz ( questions ) {
listHTML = '<ol>'
for (var i = 0; i < questions.length; i++) {
ask = prompt(questions[i][0]);
ask = ask.toLowerCase();
if (ask === questions[i][1]) {
correctAnswers ++;
}
listHTML += '<li>' + questions[i][0] + ' <strong>' + questions[i][1] + '</strong>'
}
listHTML += '</ol>'
print(listHTML);
print('You answered ' + correctAnswers + ' questions correctly!');
}
answerQuiz(quizList);
Please and thank you!
3 Answers

Anton Klyuchkovksiy
8,327 PointsOh, I get it :) You compare user input in lower case with answers, which are not.
ask = prompt(questions[i][0]);
ask = ask.toLowerCase();
if (ask === questions[i][1].toLowerCase()) {
correctAnswers++;
}
This one is works.
Or you can edit your replies in "questions" array:
"python", "emmanuel macron", "ruby", "javascript"

Solace Enwere
15,102 PointsNo, I just changed it on workspace and still not keeping count.

Solace Enwere
15,102 PointsOh I see! thanks! It works great! I didn't realize I had turn both of them to to lower case for it to match up.
Thanks Anton!