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

maria ramirez
maria ramirez
12,068 Points

My program won't start

What is wrong with my code. My program is not running

var score = 0;
var firstAnswer = prompt ("What is the complementary color for red?");
var secondAnswer = prompt ("Is black a color?");
var thirdAnswer = prompt("What color do perfect complementary colors mixed together should produce?");
var fourthAnswer = prompt ("What is the base for acrylic paint?");
var fifthAnswer = prompt("How many colors are in the rainbow?");
if (firstAnswer.toLowerCase === "green") {
    score +=1;
}
if (secondAnswer.toLowerCase === "no" || secondAnswer.toLowerCase === "false"){
    score +=1;
}
if (thirdAnswer.toLowerCase === "gray") {
    score +=1;
}
if (fourthAnswer.toLowerCase === "water") {
    score +=1;
}
if (fifthAnswer.toLowerCase === "seven" || fifthAnswer === "7") {
    score +=1;
}
document.write("<p> You scored " + score + " questions right!</p>");
if (score === 5) {
    alert("Congratulations!, you get a gold crown!");
}
elseif (score < 5 && score >= 3 ) {
    alert ("You get a silver crown!");
}
elseif (score < 3 && score >= 1) {
    alert ("You get a bronze crown"); 
}
else {
    alert ("Please try again");
}
Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

I think you have a few typos in those final "alert" functions, you have a white space between the "alert" keyword and the parenthesis. alert("You get a silver crown!"); alert("You get a bronze crown!"); alert("Please try again");

I hope that helps.

1 Answer

Ken Howard
STAFF
Ken Howard
Treehouse Guest Teacher

Change your elseif's to else if and you'll be good to go!

maria ramirez
maria ramirez
12,068 Points

Thanks! this helped a lot. I also noticed I was missing the () after toLowerCase