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

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
Bella Bradbury
Web Development Techdegree Student 12,709 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
218,692 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: