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 trialYessenia Bojorquez
727 PointsConditional Challenge
Hello,
Could someone advise on what I'm missing to run the message at the end? Thanks!
let correctguess=0;
/*
- 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
/*
- 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?");
/*
- 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
Adam N
70,280 PointsAre 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.