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 trialDanilo Rodriguez
1,663 PointsPrompting with 2 dimensional arrays.
I wrote this code without using 2 dimensional arrays and it works but after trying again with 2-D arrays I have a problem. It says theres a problem in line 10 (where my prompt is) but that part of the code runs fine when previewed.
var questions = [
["What's my first name?","Danilo"],
["What's my middle name?","Armand"],
["What's my last name?", "Rodriguez"]
]
var correctAnswers;
var wrongAnswers;
for (var i = 0; i < 4; i += 1){
var answer = prompt(questions[i][0]);
if (answer === questions[i][1]) {
correnctAnswers +=1} else {wrongAnswers +=1}
}
document.write("You answered " + correctAnswers + " correctly and " + wrongAnswers + " incorrectly.")
1 Answer
Randy Layne
Treehouse ModeratorHi Danilo, when you look at your correct answers counter after the if
conditionals, there is a typo correnctAnswers
should be correctAnswers