Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,887 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.