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 trialsergiolantigua
7,424 PointsI did the quiz, but not only with response of numbers, as well there was responses of letters. this my solution well?
Here I leave the snapshot
1 Answer
Jacie Fortune
8,969 PointsMy answers were also a mix of strings and numbers. I used the == comparison instead of === because it doesn't compare type. Here's my solution.
<p> <code> var quiz = [['What color do yellow and blue make?', 'green'], ['How many months are in a year?', 12], ['How many states are in the United States?', 50]]; var answer; var correct = 0;
function print(message) {
document.write(message);
}
for (var i=0; i<quiz.length; i+=1) {
answer = prompt(quiz[i][0]).toLowerCase();
if (answer == quiz[i][1]) {
correct += 1;
}
}
print('You got ' + correct + ' questions correct!');
</code> </p>