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 trial

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

Mohsen Ahmad
Mohsen Ahmad
2,699 Points

This code is just returning question1 correctly. Even though I answer all correctly i just get 1/5. Can anyone help?

var rightAnswers = 0;

var question1 = prompt("How old are you?");

if (question1>"18") { rightAnswers+=1; }

var question2 = prompt("How are you?");

if (question2.toUpperCase==="GOOD") { rightAnswers+=1; }

var question3 = prompt("Are you standing?");

if (question3.toUpperCase==="YES") { rightAnswers+=1; }

var question4 = prompt("Are you playing?");

if (question4.toUpperCase==="YES") { rightAnswers+=1; }

var question5 = prompt("Do you like me?");

if (question5.toUpperCase==="YES") { rightAnswers+=1; }

document.write("<h1>You had " + rightAnswers + "/5</h1>");

if (rightAnswers===5) { document.write("Gold"); } else if (rightAnswers>=3) { document.write("Silver"); } else { document.write("Bummer"); }

2 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

Because toUpperCase is not a property, it's a function so you need to call it like this:

var question2 = prompt("How are you?");

if (question2.toUpperCase() === "GOOD") { 
    rightAnswers+=1; 
}