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.

Tristan Johnson
Courses Plus Student 3,022 PointsAsking me the questions twice?
Why is it asking me each question twice?
var questions = [ ['Ten plus two?', 12], ['Seven plus nine?', 16], ['Four plus six?', 10], ]; var correctAnswers = 0; var question; var answer; var response; var html;
function print(message) { document.write(message); }
for (var i = 0; i < questions.length; i +=1) { question = questions[i][0]; answer = questions[i][1]; response = prompt(question); response = parseInt(prompt(question)); }
1 Answer

David Abel
5,199 PointsBecause you are prompting the user twice: response = prompt(question); response = parseInt(prompt(question));
These are both prompting the user for a response. You only need: response = parseInt(prompt(question));
I also had the clean up the code a bit for it to work for me. I think you're missing a curly brace on your for loop.
Mark Miller
45,831 PointsMark Miller
45,831 PointsYou 'for' loop looks messy. I don't see the parenthesis ending after incrementing 'i' nor do I see an opening curly brace anywhere. You should have three things inside the parenthesis, separated by two semicolons. Then open the curly brace to set the execution. The var I = 0; is correct, but next should be the condition being tested. 'i' should never become larger than the length of the array that holds the questions and answers. Test for that in the parenthesis. You should increment 'i' for the third part of the parenthesis.