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

Conditional statement My code does not work after the first if statement

var score = 0; var question1 = prompt("What is the best programming language?"); if (question1.toUpperCase() === "PYTHON") { score += 1;

}

var question2 = prompt("What is the second best programming language?"); if (question2.toUpperCase() === "JAVASCRIPT") { score += 1;

}

var question3 = prompt("What city is Will Smith from?"); if (question3.toUpperCase() === "PHILADELPHIA") { score += 1;

}

var question4 = prompt("Where is Nicki Minaj from?"); if (question4.toUpperCase() === "NEW YORK") { score += 1;

}

var question5 = prompt("What color is the sun?"); if (question5.toUpperCase() === "YELLOW") { score += 1;

}

document.write("Your score is " + score);

if(score === 5) { alert("You win gold!"); }else if(score === 3 || score ==== 4){ alert("You win silver!"); }else if(score === 1 || score === 2){ alert("You win Bronze!"); }else{ alert("You Lose!"); }

Adam Beer
Adam Beer
11,313 Points

Code

Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

      ```html
      <p>This is code!</p>
      ```
var score = 0; 
var question1 = prompt("What is the best programming language?"); 
if (question1.toUpperCase() === "PYTHON") { 
  score += 1;
}

var question2 = prompt("What is the second best programming language?"); 
if (question2.toUpperCase() === "JAVASCRIPT") { 
  score += 1;
}

var question3 = prompt("What city is Will Smith from?"); 
if (question3.toUpperCase() === "PHILADELPHIA") { 
  score += 1;
}

var question4 = prompt("Where is Nicki Minaj from?"); 
if (question4.toUpperCase() === "NEW YORK") { 
  score += 1;
}

var question5 = prompt("What color is the sun?"); 
if (question5.toUpperCase() === "YELLOW") { 
  score += 1;
}

document.write("Your score is " + score);

if(score === 5) { 
  alert("You win gold!"); 
} else if(score === 3 || score ==== 4){ 
  alert("You win silver!"); 
} else if(score === 1 || score === 2){ 
  alert("You win Bronze!"); 
} else { 
  alert("You Lose!"); 
}

1 Answer

Adam Beer
Adam Beer
11,313 Points

Just a typo. Correct your code. You use 4 "=" instead of 3 "=".

} else if(score === 3 || score ==== 4){ 

to

} else if(score === 3 || score === 4){ 

Thank you!