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

jeremy lowe
jeremy lowe
3,132 Points

Challenge Quiz Help

I'm having issues on the challenge quiz. Any help is appreciated. It seems even if I answer all the questions wrong, it still adds a (+1) to the score.

var question_1 = prompt("What is stressed spelled backwards?").toLowerCase();
var question_2 = prompt("What Seseame Street character lives in a trash can?").toLowerCase();
var question_3 = prompt("What is 12 x 12?");
var question_4 = prompt("How fast is a porsche?").toLocaleLowerCase();
var question_5 = prompt("What element attack is pikachu?").toLowerCase();
var score = 0;
if ( question_1 === "desserts" ) {
  score += 1;
  console.log(score);
} if ( question_2 === "oscar" ) {
    score += 1;
    console.log(score);
} if ( question_3 === "144" ) {
  score += 1;
  console.log(score);
} if ( question_4 === "fast" ) {
  score += 1;
  console.log(score);
} if ( question_5 === "lightening" ) {
  score += 1;
  console.log(score);
} if ( score = 5 ) {
  document.write("<p>Wow, a perfect Score.  You get a gold</p>" + "Score: " + score); 
} else if ( score = 4 ) {
  document.write("<p>Great job, you earned a silver</p>");
} else if ( score = 3 ) {
  document.write("<p>Great job, you earned a bronze</p>")
} else document.write("<p>Nice try, please try again to get a medal!</p>")

Thank you

2 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Jeremy.

I have quickly tested your app in the javascript console.

The error (actually same error repeated) is at the end of your code basically:

When you check the score value, you should use === and not =, otherwise you reassign the score variable value.

Try editing those 3 "=" and it should work.

Let me know if clear.

Vittorio

jeremy lowe
jeremy lowe
3,132 Points

OMG...I knew that too. I have to remember to use "==" and "===". Its just so natural for me thinking = is =.

Thank you so much for the help