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 trialCena Sutton
3,823 PointsConditional statement My code does not work after the first if statement
var score = 0; var question1 = prompt("What is the best programming language?"); if (question1.toUpperCase() === "PYTHON") { score += 1;
}
var question2 = prompt("What is the second best programming language?"); if (question2.toUpperCase() === "JAVASCRIPT") { score += 1;
}
var question3 = prompt("What city is Will Smith from?"); if (question3.toUpperCase() === "PHILADELPHIA") { score += 1;
}
var question4 = prompt("Where is Nicki Minaj from?"); if (question4.toUpperCase() === "NEW YORK") { score += 1;
}
var question5 = prompt("What color is the sun?"); if (question5.toUpperCase() === "YELLOW") { score += 1;
}
document.write("Your score is " + score);
if(score === 5) { alert("You win gold!"); }else if(score === 3 || score ==== 4){ alert("You win silver!"); }else if(score === 1 || score === 2){ alert("You win Bronze!"); }else{ alert("You Lose!"); }
1 Answer
Adam Beer
11,314 PointsJust a typo. Correct your code. You use 4 "=" instead of 3 "=".
} else if(score === 3 || score ==== 4){
to
} else if(score === 3 || score === 4){
Cena Sutton
3,823 PointsThank you!
Adam Beer
11,314 PointsAdam Beer
11,314 PointsCode
Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.