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 trialAdam Laszlo Vincze
4,083 PointsBuild a Quiz Challenge own
Hello,
This is my quiz program. Do you think it's okay? - part 2 with teacher help -
var ques = [
['What is the world champion of formula 1 Schumacher\'s first name?', 'Michael'],
['Who was created DOS operating system?', 'Bill Gates'],
['who was the president of Apple Inc.?', 'Steve Jobs']
];
var Good =[];
var Wrong =[];
var question;
var answer;
var result;
var html;
var correct= 0;
var incorrect = 0;
function print(message) {
var out = document.getElementById('output');
out.innerHTML = message;
}
function printlist (list) {
var listhtml = '<ol>';
for(var i = 0; i < list.length; i++) {
listhtml += '<li>' + list[i] + '</li>';
}
listhtml += '<ol>';
return listhtml;
}
for (var i=0; i< ques.length; i+=1) {
question = ques[i][0];
answer = ques[i][1];
result = prompt(question);
if(result === answer) {
Good.push(question);
correct +=1;
}
else {
Wrong.push(question);
incorrect +=1;
}
}
html = '<b>'+"You got" + " " + correct + " " + "right answer(s)"+'<br>';
html += '<b>'+"The right questions are:";
html += printlist(Good);
html += '<b>'+"The wrong questions are:";
html += printlist(Wrong);
print(html);