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

The Conditional Challenge

Hello TeamTreeHouse! I found this challenge particularly challenging. I wrote rewrote and rewrote some more until I essentially gave up. No matter what I did I couldn't get the prompts to prompt. I moved on to the next video to see what the teacher had written for this particular challenge and step by step changed my code to match his looking for my error. Eventually after copying the whole challenge from the video outlining the teachers solution I STILL couldn't get this darned program to run. Please help.

/*

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

// 2. Store the rank of a player let playerRank = '';

// 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 question1 = prompt('Is this the first question?'); if (question1.toUpperCase() === 'YES') { correctAnswers += 1; } const question2 = prompt('Is this the second question?'); if (question2.toUpperCase() === 'YES') { correctAnswers += 1; } const question3 = prompt('Is this the third question?'); if (question3.toUpperCase() === 'YES') { correctAnswers += 1; } const question4 = prompt('Is this the fourth question?'); if (question4.toUpperCase() === 'YES') { correctAnswers += 1; } const question5 = prompt('Is this the fifth question?'); if (question5.toUpperCase() === 'YES') { correctAnswers += 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 ( correctAnswers === 5 ) { playerRank = "Gold"; } else if (correctAnswers >= 3) { playerRank === "Silver"; } else if (correctAnswers >= 1) { playerRank === "Bronze"; } else (correctAnswers === 0) { playerRank === "Poo"; }

// 6. Output results to the <main> element

main.innerHTML = <h2>You got ${correctAnswers} out of 5 questions correct.</h2> <p>Crown earned: <strong>${rank}</strong></p> ;

you are outputting a variable called "rank" but you are editing a variable called "playerRank". try putting ${playerRank} inside of the <strong> element.