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
Nigel Rodgers
15,777 PointsThere is a bug in the provided challenge solution
In the JavaScript Basics Conditional Challenge there is a bug in the code provided to download. The original code is like this:
// output rank
if ( correct === 5 ) {
document.write("<p><strong>You earned a gold crown!</strong></p>");
} else if (correct > 3) {
document.write("<p><strong>You earned a silver crown.</strong></p>");
} else if (correct > 2) {
document.write("<p><strong>You earned a bronze crown.</strong></p>");
} else {
document.write("<p><strong>No crown for you. You need to study.</strong></p>");
}
I think it should be like this:
if ( correct === 5 ) {
document.write("<p><strong>You earned a gold crown!</strong></p>");
} else if (correct > 2) {
document.write("<p><strong>You earned a silver crown.</strong></p>");
} else if (correct > 0) {
document.write("<p><strong>You earned a bronze crown.</strong></p>");
} else {
document.write("<p><strong>No crown for you. You need to study.</strong></p>");
}
Nigel Rodgers
15,777 PointsSimon Coates
28,695 Pointsthe code does differ from what he shows in the video, and your code seems to better reflect the requirements.
1 Answer
Adam Pengh
29,881 PointsThe code provided in the video download is correct. Below is the code from the downloaded solution. Please note that in your code, you have the "if" statement on the same line as the comment, which may be why you're seeing an issue.
// output rank
if ( correct === 5 ) {
document.write("<p><strong>You earned a gold crown!</strong></p>");
} else if (correct > 3) {
document.write("<p><strong>You earned a silver crown.</strong></p>");
} else if (correct > 2) {
document.write("<p><strong>You earned a bronze crown.</strong></p>");
} else {
document.write("<p><strong>No crown for you. You need to study.</strong></p>");
}
Simon Coates
28,695 PointsIn the video the conditions are slightly different. ===5, >= 3, >= 1. I'm assuming that was the reason for complaint, not any problem with actual execution.
Nigel Rodgers
15,777 PointsThe code in the video download is correct but the code in the zip file download isn't.
I mean the zip file and video have different code. I hadn't checked out the video first that's why there's confusion.
the path to the file is inside zip is:
/Treehouse_JavaScript_Basics/Stage_04/challenge_solution/
Simon Coates
28,695 PointsSimon Coates
28,695 PointsIt's possible to link to a video or a challenge. Absent this, a url will help people know what this is about.