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 trialImmanuel Jaeggi
5,164 PointsPoints dont tally up
Hi I used the method .toUppercase() w/o looking at the teachers notes but still cannot find my error, which is a "0 out of 5" message when I should get atleast some points.
Here is my code:
var correct = 0;
// begin questions var ans1 = prompt("Welcome to the quiz! Here is your first question: What is the capital of Mongolia?"); if (ans1.toUpperCase() === "Ulaanbaatar") { correct += 1; }
var ans2 = prompt("What city is known as the big Apple?"); if (ans2.toUpperCase() === "New york") { correct += 1; }
var ans3 = prompt("Are chimps apes or monkeys?"); if (ans3.toUpperCase() === "apes") { correct += 1; }
var ans4 = prompt("In which country is Timbuktu in?"); if (ans4.toUpperCase() === "Chad") { correct += 1; }
var ans5 = prompt("Where were French fries invented?"); if (ans5.toUpperCase() === "Belgium"){ correct += 1; }
// output results document.write("<p>You got " + correct + " questions correct out of 5.</p>");
2 Answers
Antti Lylander
9,686 Points(ans2.toUpperCase() === "New york") will never ever be true because 'New york' is not equal to 'NEW YORK'.
Chris Pulver
7,624 PointsTo expound on what Antti said, your string values in the conditional statements all need to be fully capitalized ("NEW YORK", "BELGIUM", etc). toUpperCase capitalizes all letters, not just the first.