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

I have no idea what I did wrong, it doesnt work at all

  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');
  4. Ask at least 5 questions
   - Store each answer in a variable
   - Keep track of the number of correct answers
const a1 = prompt("1+1???");
if (a1==2){
  5. 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===1){
  rank = "Bronze";
// 6. Output results to the <main> element
main.innerHTML = `
  <h2>Hi ${rank}</h2>
Mark Casavantes
Mark Casavantes
2,866 Points

Hi Rafael,

I do not find your five questions you are asking or your programming to evaluate the ranking of your player based on correct answers.

https://teamtreehouse.com/library/the-conditional-challenge-solution-2 goes overy this problem with a solution.

I hope this is helpful.

1 Answer

Charlie Bird
Charlie Bird
4,504 Points

Hi Rafael, I've tried your code and it seems to work for me.

Have you made sure that your index.html file is linking correctly to quiz.js? This challenge uses a different workspace to the previous videos on this course so you may still be using the old html.