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 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,485 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!?