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

Alexandra Wakefield
Alexandra Wakefield
1,866 Points

My Solution! What Do You Think?

var questions = [
  ["What is the name of the first of the three thoracic segments of an insect?",
  ["What is the name of tongue-like structure that molluscs use to scrape up food?",
  ["What is the fibrous protein that makes up many sponge frameworks?",
  ["What is the pincher-like appendage that some crustaceans and arachnids have?",
  ["What is the name of the beak of a bivalve?",

var rightAnswer = "";
var wrongAnswer = "";

//Asking the questions from above and recording if their answers are coreect or not.

for(j = 0; j < questions.length; j++) {
  var answer = prompt(questions[j][0]);
  var questionNum = j + 1;
  if(answer.toLowerCase() === questions[j][1]) {
    rightAnswer += "<ol>" + questionNum + ".) " + questions[j][0] +
    "<ul>Your Answer = " + answer + "</ul>" + "</ol>";
  } else {
    wrongAnswer += "<ol>" + questionNum + ".) " + questions[j][0] +
    "<ul>Your Answer = " + answer + "</ul>" +
    "<ul>Correct Answer = " + questions[j][1] + "</ul>" + "</ol>";

function printAnswers(message) {

printAnswers("<h2><b>Questions Answered Correctly</b></h2>" + "<list>" + rightAnswer + "</list>");
printAnswers("<h2><b>Questions Answered Incorrectly</b></h2>" + "<list>" + wrongAnswer + "</list>");

1 Answer

Steven Parker
Steven Parker
215,939 Points

I think you got it, mostly. :smile:

Functional, concise, and readable. Good job! :+1:

You only have some minor HTML structure/syntax issues:

  • the direct child elements of lists (either ol or ul) should all be list items (li).
  • I don't think "<list>" is a real HTML tag.

It doesn't look like you really need lists here, just a bit of indentation. You could use <blockquote> tags or a bit of CSS styling to get the effect you want.

Alexandra Wakefield
Alexandra Wakefield
1,866 Points

Thank you!

Haha, you're totally right, <list> is definitely not an HTML tag, but [list] is a BBCode one and I think I accidentally mixed the two.