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

Elena Paraschiv
Elena Paraschiv
9,938 Points

the output does not display right

When I am testing the ranking it does not seem to display correct. What is the problem?

/* in the beginning 0 of them are correct*/
var  correct = 0;


/*ask the questions*/

var questionOne = prompt("What is a snake?");
if (questionOne.toUpperCase() === "PYTHON") {
 correct += 1;
}



var questionTwo = prompt("What is a gem?");
if (questionOne.toUpperCase() === "RUBY") {
  correct += 1;
}



var questionThree = prompt("What is first language?");
if (questionOne.toUpperCase() === "HTML") {
  correct += 1;
}




var questionFour = prompt("What is second language?");
if (questionOne.toUpperCase() === "CSS") {
  correct += 1;
}




var questionFive = prompt("What is third language?");
if (questionOne.toUpperCase()==="JAVASCRIPT") {
  correct += 1;
}




/*Ranking*/

if (correct === 5 ){
    document.write("<p><strong>You have recieved the golden crown</strong></p>");
}

else if(correct >= 3 ){
    document.write("<p><strong>You have recieved the silver crown</strong></p>");
}
else if (correct >= 1){
        document.write("<p><strong>You have recieved the bronze crown</strong></p>");
    }
else {
     document.write("<p><strong>You got squashed</strong></p>");                  
  }

1 Answer

Jeff Lemay
Jeff Lemay
14,268 Points

In all your if statements where you check the answers, you are checking against questionOne only (copy/paste error).

if (questionOne.toUpperCase() === "RUBY") {
// should be
if (questionTwo.toUpperCase() === "RUBY") {
Elena Paraschiv
Elena Paraschiv
9,938 Points

missed that one.Thanks Jeff!