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 Solution

I cannot get my code to give me my correct results.

var correct = 0;


var answer1 = prompt("What does HTML stand for");
if ( answer1.toUpperCase() === 'true' ) {
        correct ++;
}
var answer2 = prompt("What does CSS stand for");
if ( answer2.toUpperCase() === 'true' ) {
        correct ++;
}
var answer3 = prompt("What does JS stand for");
if ( answer3.toUpperCase() === 'true' ) {
        correct ++;
}
var answer4 = prompt("What day is it today?");
if ( answer4.toUpperCase() === 'true' ) {
        correct ++;
}
var answer5 = prompt("Am I happy that I am coding?");
    if ( answer5.toUpperCase() === 'true' ) {
        correct ++;
}


document.write("<p>You got " + correct + " many questions correct</p>");


if ( correct === 5 ) {
    document.write("<p>You earned a gold star!</p>");
}   else if ( correct >= 3 ) {
    document.write("<p>You earned a silver star!</p>");
}   else if ( correct >= 1) {
    document.write("<p>You earned a bronze star!</p>");
}   else {
    document.write("<p>You earned no star!</p>");
}

1 Answer

Christopher Villarreal
Christopher Villarreal
6,603 Points

So I reviewed your code and so far there's one problem I can see that's repeated multiple times. For your IF statements, they should equal the correct answer in caps instead of true. I have provided one part for you to look at, I included the old and edited version. Hope this helps you :)

old

            var answer1 = prompt("What does HTML stand for");
            if ( answer1.toUpperCase() === 'true' ) {
                    correct ++;
            }

New

            var answer1 = prompt("What does HTML stand for");
            if ( answer1.toUpperCase() === 'HYPERTEXT MARKUP LANGUAGE' ) {
                    correct ++;
            }

My hero! Thank you very much.