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. Is my solution ok?

var questions = [["What is 1+1?", "What is 2+3?", "What is 9-2?", "What is 5-1?"],
[2, 5, 7, 4]
];

var n = 0;
var correctAnsw = [];
var failedAnsw = [];

while(n < 4){
var allQuestions = prompt(questions[n]);
if (allQuestions == questions[n]){
alert("Correct, the number is: " + questions[n]);
correctAnsw.push(questions[n]);
}else{
failedAnsw.push(questions[n]);
}
n += 1;
}
document.write("<br>" + "The correct answers are: " + "<br>" + correctAnsw.join(", " + "<br>"));
document.write("<br>" + "The incorrect answers are: " + "<br>" + failedAnsw.join(", " + "<br>"));

Hi Seb, most of your code is good. Just two little errors, which are:

In the conditional statement in your 'while' loop when you used the 'push' method to add the correct and incorrect answers in their respective array literals. You were pushing in 'questions[n]' (which is the array of questions)

if (allQuestions == questions[n]){
alert("Correct, the number is: " + questions[n]);
correctAnsw.push(questions[n]);
}else{
failedAnsw.push(questions[n]);
}

when it should be 'questions[n]' (which is the array of answers) just as you used in your alert dialog on the line just above.

if (allQuestions == questions[n]){
alert("Correct, the number is: " + questions[n]);
correctAnsw.push(questions[n]);
}else{