Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 1

3 Answers

Steven Parker
Steven Parker
220,853 Points

There's still a few more issues to be addressed:

  • the loop only asks the questions, the scoring code is outside the loop
  • since the answers are all numbers, the "guess" must be converted to match
  • the index for the answer should be "[i][1]", not "[0][i]"
  • questionsCorrect should be assigned with the concatenating operator ("+=")
  • both "questionsCorrect" and "wrong" should be initialzed to an empty string
Steven Parker
Steven Parker
220,853 Points

At first glance, I notice two things in "quiz.js:

  • on line 23 you call "propt", but you don't store the value it returns anywhere
  • on line 24 you attempt to convert the questions array into a number

I'd guess that a new variable (first to store, then convert from) should be involved in both lines.

slurpee
slurpee
6,694 Points

fix some errors, but don't understand what you mean by storing the value so it returns anywhere. not quite sure on how to do that. well just confuse

Steven Parker
Steven Parker
220,853 Points

You might use an assignment to save the result of using "propt", as in this generic example:

var someVariable = prompt("a prompt question");

Calling "prompt" without the assignment asks the question, but whatever answer the user types is lost.