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 trialGlen Segers
1,223 Pointslooking for some input on my challenge
var score = 0;
var question1 = prompt("red or black?");
if (question1 === "red") {
score++
}
var question2 = prompt("dog or cat?");
if (question2 === "dog") {
score++
}
var question3 = prompt("car or bike?");
if (question3 === "bike") {
score++
}
var question4 = prompt("beer or wine?");
if (question4 === "beer") {
score++
}
var question5 = prompt("day or night?");
if (question5 === "night") {
score++
}
alert("You scored: " + score + " on 5");
if (score === 5) {
alert("You gained a Gold Crown")
} else if (score === 3 || score === 4) {
alert("You gained a Silver Crown")
} else if (score === 1 || score === 2) {
alert("You gained a Bronze Crown")
} else {
alert("Sorry, no crown for you")
}
alert("Thank you for playing")
2 Answers
Steven Parker
231,269 PointsThe code looks great! Good job.
The questions could use a little work.
Aaron Mckenzie-Hunte
10,741 PointsI would add the .tolowercase() method around your variables in the conditional statement. If the user enters "Red" for question1 it will be classed as false.
Glen Segers
1,223 Pointsthank you, and you are right, forgot about that issue.
Glen Segers
1,223 PointsGlen Segers
1,223 PointsThanks :D
Yea i know, needed to get some sleep xD