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 Arrays Multidimensional Arrays Improve the Quiz – One Solution

Amani Wainaina
Amani Wainaina
6,722 Points

Uncaught TypeError: Cannot read properties of undefined (reading '0')

I am getting this error from this line of code : let question = questions[i][0];

I am not sure what I am doing wrong. Any help would really be appreciated.

3 Answers

Steven Parker
Steven Parker
231,172 Points

It sounds like perhaps the "questions" array isn't set up correctly, or the index "i" isn't valid for it. We'd need to see the rest of the code to tell exactly.

To share the entire project, make a snapshot of your workspace and post the link to it here.

Steven Parker
Steven Parker
231,172 Points

Now that I've seen the snapshot, it was my first guess. On line 4 of quiz.js, there should be a comma at the end of the line to separate the second question from the third. Without it, the contents of the array's second element are undefined.

Amani Wainaina
Amani Wainaina
6,722 Points

Ok, here is the link to the snapshot of my workspace. https://w.trhou.se/thmzfhcnhy

Amani Wainaina
Amani Wainaina
6,722 Points

Thank you, it is working now.