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

This isn't adding up

/* 
  1. Store correct answers
   - When quiz begins, no answers are correct
*/

let correctAnswer = 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 q1 = prompt(` Are multi-line comments started and ended with " /* */ " `);

if (q1.toUpperCase() === 'YES' || q1.toUpperCase() === 'Y'){
  correctAnswer +=1;
  console.log(correctAnswer);
} 


const q2 = prompt(` Are single  comments started and ended with " //  " `);

if (q2.toUpperCase() === 'YES' || q1.toUpperCase() === 'Y'){
  correctAnswer +=1;
  console.log(correctAnswer);
} 


const q3 = prompt(` Are you learning JavaScript ???" `);
if (q3.toUpperCase() === 'YES' || q1.toUpperCase() === 'Y'){
  correctAnswer +=1;
  console.log(correctAnswer);
} 


const q4 = prompt(`Does this quiz suck ???`);
if (q4.toUpperCase() === 'YES' || q1.toUpperCase() === 'Y'){
  correctAnswer +=1;
  console.log(correctAnswer);
} 


const q5 = prompt(` are we done yet ????`); \\jokes
if (q5.toUpperCase() === 'YES' || q1.toUpperCase() === 'Y'){
  correctAnswer +=1;
  console.log(correctAnswer);
} 



/*
  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 ( correctAnswer === 5){
rank =`👑👑👑👑👑 Gold`;
} else if( correctAnswer >= 3 ) {
 rank =`👑👑👑 Silver`;
} else if( correctAnswer >= 2 ){
 rank =`👑👑 Bronze`;
} else
  rank = `No Crown`;


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

let results = `<p> The results is you got ${rank}</p>`;

main.innerHTML = results;

1 Answer

Bella Bradbury
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Front End Web Development Techdegree Graduate 32,788 Points

I'm looking into this issue, but you've posted your question twice. I will respond on the other question, please mark this "answer" as the best answer on this post to avoid any confusion!

Steven Parker
Steven Parker
228,991 Points

A better way to handle a duplicate is to delete it by clicking the little rectangle with the 3 dots to reveal the option to "Delete Question". But only questions with no answers can be deleted, so you'll need to delete this "answer" first to allow the asker to delete the question!

In future, notify an asker of a duplicate using a comment instead of an "answer". :see_no_evil: