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 trialRENZ G
1,351 PointsThe output is giving me "0" whereas I've answered all the questions correctly. Please help where did i missed?
//Default Score var correct = 0;
//Quiz Questions var questionOne = prompt("What is the capital of Philippines?"); if (questionOne.toUpperCase() === "manila") { correct += 1; }
var questionTwo = prompt("What is the capital of Japan?"); if (questionTwo.toUpperCase() === "tokyo") { correct += 1; }
var questionThree = prompt("What is the capital of Thailand?"); if (questionThree.toUpperCase() === "bangkok") { correct += 1; }
var questionFour = prompt("What is the capital of Malaysia?"); if (questionFour.toUpperCase() === "kuala lumpur") { correct += 1; }
var questionFifth = prompt("What is the capital of Australia?"); if (questionFifth.toUpperCase() === "sydney") { correct += 1; }
//Output Results document.write("You got " + correct + " out of 5 questions correct. ");
//Output Rank
if (correct === 5) { document.write("Perfect! you got GOLD medal."); } else if (correct >= 3) { document.write("You earned SILVER medal."); } else if (correct >= 1) { document.write("You earned BRONZE medal."); } else { document.write("Please study and try again."); }
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! You're doing great, but you're taking the user's answer and then turning it to upper case then comparing it to the answer which is all in lower case.
Let's assume I'm answering question two, and I put in "Tokyo". Your code then turns my answer into "TOKYO" and asks if it's equal to "tokyo". Either you need to turn the user's answers into lower case or you need to compare to the upper case version of the answer.
Hope this helps!
RENZ G
1,351 PointsRENZ G
1,351 PointsHey Jennifer, thanks for the help! work well now! :)