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 Data Using Objects The Build an Object Challenge, Part 1

Alex Forseth
Alex Forseth
8,017 Points

Why wont my first question prompt in the make a quiz challenge?

After live previewing several times I am still unsure as to why the code below will not at the very least prompt one question. Any help would be greatly appreciated. Thanks.

// Questions

var questions = [
            ['Who is the President of the U.S?', 'Donald Trump'],
            ['Whos is the Vice President of the U.S?', 'Mike Pence'],
            ['Who won the Super Bowl last year?', 'Patriots']
];

//Variables go here, answer, response, question ect
var correctAnswers = 0;
var question;
var answer;
var response;
var html;

function print(message) {
  document.write(message);
}

    //below is how you loop the questions above 
for (var i = 0; i < questions.length; i += 1); {
    question = questions[i][0];
    answer = questions[i][1];
    response = prompt(question);
}

1 Answer

Steven Parker
Steven Parker
231,236 Points

There's a stray semicolon in the "for" loop between the closing parenthesis of the loop expressions and the opening brace of the code block.

Alex Forseth
Alex Forseth
8,017 Points

Thank you! facepalm

Steven Parker
Steven Parker
231,236 Points

Ahh, you're having the feeling of a "growth experience". :wink: