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

Only number correct/wrong displays in li not actual question

This is the code pen... I'm dyin' over here. Basically the issue is that when I finish the test it doesn't display the question variable with array value QNA[i][0], instead it just shows the number of questions I got right or wrong in the appropriate <li>. I have a feeling that the issue has something to do with the for loop or the if else statement from lines 34- 47. But that's just what I think, and that might be the same reason I'm not finding the error. Thanks in advance! Bryan

<p data-height="508" data-theme-id="9704" data-slug-hash="zxyJoJ" data-default-tab="result" data-user="bryvl" class='codepen'>See the Pen <a href='http://codepen.io/bryvl/pen/zxyJoJ/'>zxyJoJ</a> by Bryan Valencia (<a href='http://codepen.io/bryvl'>@bryvl</a>) on <a href='http://codepen.io'>CodePen</a>.</p> <script async src="//assets.codepen.io/assets/embed/ei.js"></script>

2 Answers

Hey Bryan Valencia,

Your problem was this line right here:

listHTML += '<li>' + arr.length + '</li>';

In this, you are going to have the number 3 in your list item. Instead, what you want is the value of each index in the array. And it's very simple to change that:

listHTML += '<li>' + arr[i] + '</li>';

Now, it will take the current index value, i, and use it with the given array (arr) and place the value into the list item. Once I changed that, your program worked as expected. It built the correct list items in the appropriate places!

Thanks man, half asleep right now. Can't believe I overlooked that lol.

Haha totally understandable! No problem! Happy and awake coding to you! :D