Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

Dylan Merritt
Dylan Merritt
15,682 Points

My 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

Hi 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
Dylan Merritt
15,682 Points

Thanks so much. Can't believe I missed that!