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 trialGrant Polhemus
7,093 PointsShouldn't the Bronze rank else if statement be >=1, not >=2?
The instructions say a Bronze rank should be awarded if the player answers 1-2 questions correct. In the video, Guil writes:
else if ( correct >= 2 ) { rank = "Bronze"; }
This means that a Bronze rank is awarded to someone who answers 2 or more questions correct. That means no rank is awarded to a player who only gets one correct. I changed it to:
else if ( correct >= 1 ) { rank = "Bronze"; }
and it worked.
2 Answers
Catherine Wu
5,033 PointsYou're right, I noticed that too. They've since made a correction in the teacher's notes.
Kevin Narain
11,379 PointsI used the logical OR to solve this problem.
if(correct === 5) {
rank = "Gold";
} else if (correct >= 3) {
rank = "Silver";
} else if (correct === 2 || correct === 1) {
rank = "Bronze";
} else {
rank = "None :(";
}