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

Eugen Oanta
Eugen Oanta
5,657 Points

My script is not running when pressing Preview

So it looks like after adding the buildList function the script is not longer firing. Here is the link to my code : https://w.trhou.se/z8aufban8r Also if I comment the buildList section, it works.

I am very confused, the code looks the same as in the video. Can anyone take a look? Ty.

3 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! No it's not. And I've found the problems. There are two.

First, and foremost, your Javascript is not linked correctly in your html file.

You have written:

<script src="/js/quiz.js"></script>

That should be:

<script src="js/quiz.js"></script>

Secondly, there's an error in your for loop in your Javascript file on line 20. You've written:

for (x = 0, x < arr.length, x += 1)

Those should be semicolons, not commas:

for (x = 0; x < arr.length; x += 1)

When I make these changes, and refresh the browser your code runs! Hope this helps! :sparkles:

Cindy Lea
Cindy Lea
Courses Plus Student 6,497 Points

On first glance I noticed this:

 if (response === answer) {

Should be ==

Try that & report back :)

Eugen Oanta
Eugen Oanta
5,657 Points

Thank you for your replies, fortunately I have discovered it afterwards, like Jennifer says , the problem were the missing semicolons in the for loop arguments. Thank you again..