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 trialGremyko Coleman
9,756 Pointseverything working except the print function
<!-- this part of the code isn't printing on the screen
>>>> print("You Got " +correctScore +" right"); <<<<
-->
var questions = [
["What Was The First State Of The U.S?", "Delware"],
["What Year Did The NBA Add The 3-point Line?", 1980],
["What color is the sky?", "Blue"]
];
function print(message) {
document.write(message);
}
function quiz(theQuestions){
var correctScore=0;
var correctQuestions;
var wrongScore=0;
var wrongQuestions;
for(var i = 0; i < theQuestions.length; i++){
var question = prompt(theQuestions[i][0]);
}if(question === theQuestions[i][1]){
correctScore++;
}else{
wrongScore++;
}
print("You Got " +correctScore +" right");
}
quiz(questions);
1 Answer
Steven Parker
231,269 PointsThe "print" function itself is OK, but there's an error that ends the program before it gets to it.
Currently the loop ends before the "if", but the "if" uses the loop variable "i" and should be inside the loop.
Gremyko Coleman
9,756 PointsGremyko Coleman
9,756 PointsThanks that worked