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

Angie Clark
seal-mask
.a{fill-rule:evenodd;}techdegree
Angie Clark
Front End Web Development Techdegree Student 19,986 Points

'[0]Property undefined' Console error on the 'question = questions[i][0];' part of the code.

https://w.trhou.se/hyp21hunps At the point where we can first test the quiz, I get nothing. The error in the console says 'Cannot ready property [0] of undefined. So can you help me see where am I going wrong?

1 Answer

Andreas Nyström
Andreas Nyström
8,882 Points

It seems like you're missing a "," after your first item in the first array "questions".

var questions = [
  ['How many states are in the United States?',50]
  ['How many continents are there?', 24],
  ['How many legs does and insect have?', 6,]
];

Should be

var questions = [
  ['How many states are in the United States?', 50],
  ['How many continents are there?', 24],
  ['How many legs does and insect have?', 6]
];

I hope this helps.