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 trialRafael Lourenço
Front End Web Development Techdegree Student 631 PointsI have no idea what I did wrong, it doesnt work at all
/*
1. Store correct answers
- When quiz begins, no answers are correct
*/
let correct = 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 a1 = prompt("1+1???");
if (a1==2){
correct+=1;
}
/*
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 (correct===1){
rank = "Bronze";
}
// 6. Output results to the <main> element
main.innerHTML = `
<h2>Hi ${rank}</h2>
<p>HI</p>
`;
1 Answer
Charlie Bird
7,277 PointsHi Rafael, I've tried your code and it seems to work for me.
Have you made sure that your index.html file is linking correctly to quiz.js? This challenge uses a different workspace to the previous videos on this course so you may still be using the old html.
Mark Casavantes
2,880 PointsMark Casavantes
2,880 PointsHi Rafael,
I do not find your five questions you are asking or your programming to evaluate the ranking of your player based on correct answers.
https://teamtreehouse.com/library/the-conditional-challenge-solution-2 goes overy this problem with a solution.
I hope this is helpful.