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

there is something wrong with my code could u tell me what is it


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

/* the questions and the answers */ const earth = prompt ("What planet we are on ?"); const water = prompt ("What is the 70% of your body?"); const degree = prompt ("What is the boiling water degree?"); const blue = prompt ("What color is the ocean?"); const white = prompt ("What is the color of the sun?");

/* we mad correctAnswers to count how many point the player will get */

let correctAnswers =0;

if (earth.toUpperCase === "EARTH") { correctAnswers +=1; } if (water.toUpperCase === "WATER") { correctAnswers +=1; } if (degree.toUpperCase === "DEGREE") { correctAnswers +=1; } if (blue.toUpperCase === "BLUE") { correctAnswers +=1; } if (white.toUpperCase === "WHITE") { correctAnswers +=1; }

const points5= <h2>Gold</h2>; const points43= <h2>Silver</h2>; const points21= <h2>Bronze</h2; const points0= <h2>No Crown</h2>;

// 2. Store the rank of a player


*/ if ( correctAnswers === 5 ){ document.querySelector('Main').innerHTML= points5 ; }else if ( correctAnswers === 4 || +correctAnswers === 3 ){ document.querySelector('Main').innerHTML= points43; }else if( correctAnswers === 2 || +correctAnswers === 1 ){ document.querySelector('Main').innerHTML= points21; }else ( correctAnswers === 0 ){ document.querySelector('Main').innerHTML= points0 ; }

1 Answer

Steven Parker
Steven Parker
229,921 Points

When posting code, always use Markdown formatting to preserve the code's appearance and retain special symbols. And for workspace projects, an even better way to share is to make a snapshot of your workspace and post the link to it here.

Now here's a couple of hints:

  • when calling a function or method, you must put parentheses after the name even if there are no arguments
  • an "else" does not need (and won't allow) a conditional expression