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 JavaScript Basics Making Decisions in Your Code with Conditional Statements The Conditional Challenge Solution

else if

if (correct === 5){
  rank = "Gold";
} else if (correct >= 3){
  rank = "Silver";
} else if (correct >= 2){ //THIS ONE!
  rank = "Bronze";
} else {
  rank = "No Crown!";
}

The second "else if" should be else if (correct >= 1), because if you've answered 1 question correctly you'll get "No crown" in this case!

Is that right?

2 Answers

Broderick Lemke
Broderick Lemke
13,483 Points

You are correct, if a user gets 1 question right in this code they will get a rank of "No Crown!". To me it looks like this was an error in logic or a typo. else if (correct >= 1) would return bronze if the user got a 1 as the comments above it listed. Good catch!

This is where proofreading code, and testing come in handy! A unit test probably would've caught this error for us and shows the importance of using testing! :)

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi there,

Yep, it is a typo. It should be (correct >= 1). I've added the correction in the teacher's notes below the video, as well as in the project files. :)

Thanks!