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

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.