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 trialarmand Rodriguez
7,830 PointsHow to get the list numbered
I figured this out on my own (lots of trial and error), and i got it working. My only question is how do i make the <ol> numbered. I was thinking of just adding it manually in the loop, but I thought ordered lists were supposed to be numbered by default.
function print(message) {
document.write(message);
}
var quizScore = 0
var question;
var correctAnswer = '';
var incorrectAnswer = '';
var quizQA = [
['Who wrote the book, "Flags in the Dust?"', 'william faulkner'],
['What is the capital city of Japan?', 'tokyo'],
['Analog gear utilizes even or odd harmonics?', 'even'],
];
for ( i = 0; i < quizQA.length; i += 1 ) {
question = prompt(quizQA[i][0]);
if ( question === quizQA[i][1].toLowerCase() ) {
quizScore += 1;
correctAnswer += quizQA[i][0] + "<br>";
} else {
quizScore += 0
incorrectAnswer += quizQA[i][0] + "<br>";
}
}
print("<h1>Your got the following questions correct:</h1><br>" + "<ol>" + correctAnswer + "</ol>");
print("<h1>Your got the following questions incorrect:</h1><br>" + "<ol>" + incorrectAnswer + "</ol>");
print("<h2>Your Score is " + quizScore + ".</h2>");
2 Answers
Tsenko Aleksiev
3,819 Points[http://blog.teamtreehouse.com/customize-ordered-lists-pseudo-element] Thanks to Dave! Hope this helps :)
Joshua Miller
7,824 PointsMake each correct or incorrect answer a list item:
for ( i = 0; i < quizQA.length; i += 1 ) { question = prompt(quizQA[i][0]); if ( question === quizQA[i][1].toLowerCase() ) { quizScore += 1; correctAnswer += "<li>" + quizQA[i][0] + "</li>"; } else { quizScore += 0 incorrectAnswer += "<li>" + quizQA[i][0] + "</li>"; } }