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 2 Solution

Hui Zheng
PLUS
Hui Zheng
Courses Plus Student 1,380 Points

My code wouldn't produce the same result

I only made a small change to the example from the video, instead of having the assignment of the response variable in 2 separate statements I combined them into one single statement. Besides that, I had typed everything else verbatim and had re-watched the video three times to make sure I had no typos on my code. But I couldn't figure out what I had done wrong and how come I was not able to get the same result.

Here is the link to what I had done: https://teamtreehouse.com/workspaces/40977780#

Steven Parker
Steven Parker
231,269 Points

You can't share a direct URL to your workspace, it's temporary and only exists while you are using it.

But you can use the snapshot function in the workspace and provide the link to that.

1 Answer

Steven Parker
Steven Parker
231,269 Points

I found "index.html" inside the "css" folder, so before it would run I had to move it to the main folder.

Then I discovered two issues in "quiz.js":

  • the assignment on line 23 should be a concatenating assignment instead ("+=")
  • around line 36, a closing bracket is missing to complete the "for" loop (that starts on line 27)
Hui Zheng
Hui Zheng
Courses Plus Student 1,380 Points

I did move the index.html file down to the js folder. On line 23 I did it according to how it was done in the video by closing the ol tag. On line 36, I went back and added the closing bracket nonetheless I still didn't get the result I expected.

Here is the link -- https://w.trhou.se/s8xm70sosp

Steven Parker
Steven Parker
231,269 Points

The index file needs to be in the root folder, not in either subfolder. Once I moved it up, the program ran as expected for me.