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

William Coshburn
William Coshburn
6,125 Points

I get an error right away with my 3rd question , then I get another with call to the variable question

question = questions[i][0];

console says that it cannot read the property '0'.

Can this quiz be created without the arrays?

Can you post all your code?

3 Answers

William Coshburn
William Coshburn
6,125 Points

I appreciate it, it's probably just me being awful at this. I couldn't even get this started. I would have done this without the arrays.

var questions = [

['Who is the GOAT?', 'Michael Jordan'] ['Where do the Cowboys play?', 'Dallas']

];

var correctAnswers =0; var question; var response; var html;

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

question = questions[i][0]; answer = questions[i][1]; response = toLowerCase(prompt(question)); }

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

your question states that you are having a problem with your third question but you only posted two.

"Who is the Goat?" and "Where do the Cowboys play?"

Upon observation of your code. you have set the response to lowercase but you set the answers (Michael Jordan, Dallas) with capitals.

I would also move your function print(message){ { document.write(message);} outside your for loop. I would put it right after you are declaring your variables.

simply, I see you don't have comma to split the sub arrays.