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

Ismar Uzeirovic
Ismar Uzeirovic
1,762 Points

Alternative version not working!?

I tried making my quiz via this route but my code does not work. Can anyone spot the reason why?

var questions = [

["Where is Arsenal from?", "London"], ["Where is Real from?", "Madrid"], ["Where is Fenerbahce from?", "Istanbul"]

];

var answer; var correctAnswer; var correct = 0;

var html;

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

alert("This quiz test your knowledge of international football clubs");

for (var i =0; i < questions.length; i+= 1) {

answer = prompt(questions[i][0]); answer = answer.toLowerCase(); correctAnswer = questons[i][1];

if (answer === correctAnswer) {

correct +=1;

}

}

html = "You got " + correct + "questions correctly!"; print(html);

2 Answers

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

I believe first off you are trying to name a variable html & I dont think you can do this as html is probably a reserved word. Change the cariable name & see if that does it.

Ismar Uzeirovic
Ismar Uzeirovic
1,762 Points

I think the instructor was also using variable named html.

I tried changing it to feedback and it did not solve the problem!?