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 1 Solution

Immanuel Jaeggi
Immanuel Jaeggi
5,164 Points

only see blank screen

Could you run through my code quickly? Results can't be seen. txs.

var quiz = [ ['What comes after 99?', 100], ['If you multiply 5 by itself, what do you get?', 25], ['How many litres of blood are there in the human body?', 40] ]; var correctAnswers = 0; var question; var answer; var response: var html;

for (var i = 0; i < quiz.length; i += 1 ) { question = quiz[i][0]; answer = quiz[i][1]; response = parseInt(prompt(question)); if (response === answer) { correctAnswers += 1; }
}

html = 'You got ' + correctAnswers + ' answers right.'; print(html);

1 Answer

If you run this through the console you'll see unexpected token on line 5.

On line 5 you end with a colon instead of a semicolon

var response: