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 trialAmani Wainaina
6,722 PointsUncaught 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
231,275 PointsIt 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.
Amani Wainaina
6,722 PointsOk, here is the link to the snapshot of my workspace. https://w.trhou.se/thmzfhcnhy
Amani Wainaina
6,722 PointsThank you, it is working now.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsNow 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.