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 trialDylan Merritt
15,682 PointsMy score is 0 no matter what and I can't figure out why. Can anyone help?
var numberCorrect = 0;
var question1 = prompt("Who was the first African American president?");
if (question1.toUpperCase == "BARACK OBAMA" || question1.toUpperCase == "OBAMA" || question1.toUpperCase == "BARACK") {
alert("#1 is correct!");
numberCorrect += 1;
}
var question2 = prompt("Who wrote the original communist manifesto?");
if (question2.toUpperCase == "KARL MARX" || question2.toUpperCase == "MARX") {
alert("#2 is correct!");
numberCorrect += 1;
}
var question3 = prompt("What city has the largest population?");
if (question3.toUpperCase == "TOKYO") {
alert("#3 is correct!");
numberCorrect += 1;
}
var question4 = prompt("What is the largest planet in the solar system?");
if (question4.toUpperCase == "JUPITER") {
alert("#4 is correct!");
numberCorrect += 1;
}
var question5 = prompt("One tablespoon is equal to how many teaspoons?");
if (question5.toUpperCase == "THREE" || parseInt(question5) === 3) {
alert("#5 is correct!");
numberCorrect += 1;
}
alert("You got " + numberCorrect + " out of 5 questions right!");
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Dylan,
In each of your calls to the .toUpperCase
method you've forgotten the parentheses.
Example:
question1.toUpperCase() == "BARACK OBAMA" // () added in
You'll have to do that for each of them.
Dylan Merritt
15,682 PointsDylan Merritt
15,682 PointsThanks so much. Can't believe I missed that!