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 trialAngel Manuel Couso Jimenez
Courses Plus Student 4,402 Pointsis all good in here??
this is my answer to this challenge, please sorry if i write something wrong , am working on my english, ;) all feedback is welcome
var quizQuestions = [
[
"Which is the most populated country in the world?",
"china"
],
[
"Where Mount Everest is located?",
"nepal"
],
[
"What is the deeppest point of the ocean?",
"mariana trench"
]
];
var correctAnswers = 0;
var correctQuestions = '<ol>';
var wrongQuestions = '<ol>';
function print(message) {
document.write(message);
}
for(var i = 0; i < quizQuestions.length; i++) {
//prompt for asking the question
var answer = prompt(quizQuestions[i][0]);
if (answer.toLowerCase() === quizQuestions[i][1]) {
//if the answer is correct:
//add 1 to the total correct answers
//add the question to the right answered questions
correctAnswers ++;
correctQuestions += "<li>" + quizQuestions[i][0] + "</li>";
} else {
//if the answer is incorrect:
//add the question to the wrong aswered questions
wrongQuestions += "<li>" + quizQuestions[i][0] + "</li>";
}
}
//close the both html tags for Ordered List
correctQuestions += "</ol>";
wrongQuestions += "</ol>";
//print the output text in the document
print("<p>You got " + correctAnswers + " question(s) right!!</p>");
print("<p>Your answer was right in this questions:</p>");
print(correctQuestions);
print("<p>Your answer was wrong in this questions:</p>");
print(wrongQuestions);
Antonio De Rose
20,885 Pointswhat is your question, I ran your code, and am getting the below
<p>You got 0 question(s) right!!</p>
<p>Your answer was right in this questions:</p>
<ol></ol>
<p>Your answer was wrong in this questions:</p>
<ol><li>Which is the most populated country in the world?</li><li>Where Mount Everest is located?</li><li>What is the deeppest point of the ocean?</li></ol>
Dave StSomeWhere
19,870 PointsDave StSomeWhere
19,870 PointsHave you tried running your code and does it work?