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 trialWilliam Coshburn
6,125 PointsI 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?
3 Answers
William Coshburn
6,125 PointsI 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); }
Ahmad Asyraf Bin Kamsir
3,814 Pointsyour 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.
Wei Zhang
260 Pointssimply, I see you don't have comma to split the sub arrays.
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 PointsCan you post all your code?