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

Part 1 solution Is this work fine ?

var question = [ ["This is question 1","a1"], ["This is question 2","a2"], ["This is question 3","a3"] ]; var correctAnswer = 0;

for (var i = 0 ; i < question.length; i +=1) { if (prompt (question[i][0]) === question[i][1]) { correctAnswer += 1 } };

print ("You got " + correctAnswer + " question (s) right");

Tim Strand
Tim Strand
22,458 Points

i dont see a question posed in this. 1) what is your question 2) correctly format your code using the Markdown Cheatsheet

1 Answer

Steven Parker
Steven Parker
212,135 Points

It sounds like you're asking if your code operates correctly. You can probably make this determination for yourself, but the one issue I see is that you have not yet defined the "print" function.

Otherwise, it looks good.