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 (Retired) Making Decisions with Conditional Statements The Conditional Challenge

Glen Segers
Glen Segers
1,223 Points

looking 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
Steven Parker
230,230 Points

The code looks great! Good job. :+1:

The questions could use a little work. :stuck_out_tongue_winking_eye:

Glen Segers
Glen Segers
1,223 Points

Thanks :D

Yea i know, needed to get some sleep xD

Aaron Mckenzie-Hunte
Aaron Mckenzie-Hunte
10,741 Points

I 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
Glen Segers
1,223 Points

thank you, and you are right, forgot about that issue.