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 Making Decisions in Your Code with Conditional Statements The Conditional Challenge Solution

not sure what i did wrong no matter what i do the score system does not work

/*

  1. Store correct answers
    • When quiz begins, no answers are correct */ let correct = 0;

// 2. Store the rank of a player let rank;

// 3. Select the <main> HTML element const main = document.querySelector('main');

/*

  1. Ask at least 5 questions
    • Store each answer in a variable
    • Keep track of the number of correct answers */ const answer1 = prompt("What is the color of the sky?"); if ( answer1.toUpperCase() === 'blue') { correct += 1; } const answer2 = prompt("What is the main color of the University of Utah?"); if ( answer2.toUpperCase() === 'red') { correct += 1; } const answer3 = prompt("Who is Thor's brother?"); if (answer3.toUpperCase() === 'Loki') { correct += 1;
      }
      const answer4 = prompt("Who made the song California Love?"); if (answer4.toUpperCase() === '2pac') { correct += 1; }
      const answer5 = prompt("What is the most popular stuffed animal?"); if (answer5.toUpperCase() === 'bear') { correct += 1; }

/*

  1. Rank player based on number of correct answers
    • 5 correct = Gold
    • 3-4 correct = Silver
    • 1-2 correct = Bronze
    • 0 correct = No crown */ if ( correct === 5 ) { rank = "Gold"; } else if ( correct >= 3 ) { rank = "Silver";
      } else if ( correct >= 1 ) { rank = "Bronze";
      } else { rank = "None :("; } // 6. Output results to the <main> element main.innerHTML= <h2>You got ${correct} out of 5 questions correct.</h2> <p>Crown earned: <strong>${rank}</strong></p> ;

1 Answer

For each of your answer comparisons, you have the form if ( answer1.toUpperCase() === 'blue')

If the value for answer1 is 'blue', then answer1.toUpperCase() will become 'BLUE', which is not equal to 'blue'. If the value for answer1 is 'BLUE', then answer1.toUpperCase() will become 'BLUE', which is not equal to 'blue'.

You could try adjusting your first comparison to compare against 'BLUE' or, if you don't want to retype them, 'blue'.toUpperCase().

Thank you for the help !!