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

Yessenia Bojorquez
Yessenia Bojorquez
727 Points

Conditional Challenge

Hello,

Could someone advise on what I'm missing to run the message at the end? Thanks!

let correctguess=0;

/*

  1. Store correct answers
    • When quiz begins, no answers are correct */ const correctQ1 = "mario galaxy"; const correctQ2 = "fire mario"; const correctQ3 = "superhuman speed"; const correctQ4 = "luigi"; const correctQ5 = "princess peach";

// 2. Store the rank of a player

const rank1= "gold"; const rank2= "bronze"; const rank3= "silver"; const rank4= "wah wah wah"; // 3. Select the <main> HTML element

/*

  1. Ask at least 5 questions
    • Store each answer in a variable
    • Keep track of the number of correct answers */ const Q1= prompt ("what is your favorite mario game?"); const Q2= prompt ("what is your favorite mario transformation?") const Q3= prompt ("what is one of marios super powers?"); const Q4= prompt ("what is mario's brother name?") const Q5= prompt ("who does mario want to rescue?");

/*

  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 (correctguess === 5 ) { rank = "Gold"; } else if (correctguess === 1 || correctguess === 2) { rank = "Bronze"; } else if (correctguess === 3 || correctguess === 4) { rank = "Silver"; } else { rank= "wah wah wah"; }

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

document.querySelector('main').innerHTML = <h2>YOU GOT: ${correctguess} out of 5 questions. </h2>; '<p> crowned earned: <strong>${rank}</strong> </p>'

1 Answer

Are the questions popping up for you? One important thing that needs to be fixed is the last line of code. innerHTML should be set to a string (a template literal works best). The h2 code on that line is not in a string at all.

Another thing to note is that the correctguess variable isn't being incremented anywhere, which means it'll always be 0 at the end.

There's a decent amount to fix here, but let me know if this gets you moving in the right direction.