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

Here is my code. I did the rankings a little different but still worked ok. What do you think?

It feels great to make my first real JavaScript project. Looking forward to the next challenge! Let me know what you would do differently. Thanks

let correctAnswers = 0;

const answer1 = prompt("What is the captial of China?"); if(answer1.toLowerCase() === "beijing"){ correctAnswers ++; }

const answer2 = prompt("What is the square root of 64?"); if(+answer2 === 8){ correctAnswers ++; }

const answer3 = prompt("How many days are there in a leap year?"); if(+answer3 === 366){ correctAnswers ++; }

const answer4 = prompt("Which planet is closest to the sun?"); if(answer4.toLowerCase() === "mercury"){ correctAnswers ++; }

const answer5 = prompt("In which state is Dallas?"); if(answer5.toLowerCase() === "texas"){ correctAnswers ++; }

var crown = ""

if(correctAnswers===5){ crown="gold crown" }else if(correctAnswers>=3){ crown="silver crown" }else if(correctAnswers>=1){ crown="bronze crown" }else { crown="participation award" } ;

let final = (<h2>You got ${correctAnswers} out of 5 answers correct.</h2> <p>You have earned a <em>${crown}!</em> </p>);

document.querySelector("main").innerHTML = ${final}