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

ian truong
ian truong
4,685 Points


for ( var i = 0; i < questionAnswer.length; i++){ question = questionAnswer[i][0]; answer = questionAnswer[i][1]; respond = parseInt(prompt(question)); }

i know that in a loop if u use i++, it adds one to the loop, but prompt(question) = [i][0]. doesn't "prompt(question)" just ask [i][0] again?

1 Answer

Mckenzie Hessel
.a{fill-rule:evenodd;}techdegree seal-36
Mckenzie Hessel
Full Stack JavaScript Techdegree Graduate 20,437 Points

Since the value of i increases with each pass through the loop, the question at [i][0] will be different each time (it will go from [1][0] to [2][0] to [3][0] to [4][0] to [5][0]).