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 trialChikanma Ibeh
1,396 PointsWhy does it keep saying bronze crown when I enter all the correct answers?
var question1 = prompt('What is my name?'); var score = 0 if (question1.toLowerCase === 'chikanma') { score += 1 }
var question2 = prompt('What school do you go to?'); if (question2.toLowerCase === 'Trinity') { score += 1 }
var question3 = prompt('What is my favorite color?'); if (question3.toLowerCase === 'Purple') { score += 1 }
if (score === 3) { alert("You have won a gold crown"); }
if (score === 2) { alert("You have won a silver crown"); }
if (score === 1 || score === 0) { alert("You have won a bronze crown"); }
2 Answers
KRIS NIKOLAISEN
54,971 PointstoLowerCase() has parentheses to indicate that it is a method. I also added semicolons in the following:
var question1 = prompt('What is my name?');
var score = 0;
if (question1.toLowerCase() === 'chikanma'){
score += 1;
}
var question2 = prompt('What school do you go to?');
if (question2.toLowerCase() === 'trinity'){
score += 1;
}
var question3 = prompt('What is my favorite color?');
if (question3.toLowerCase() === 'purple') {
score += 1;
}
if (score === 3) { alert("You have won a gold crown"); }
if (score === 2) { alert("You have won a silver crown"); }
if (score === 1 || score === 0) { alert("You have won a bronze crown"); }
KRIS NIKOLAISEN
54,971 PointsBoth of the following will never be true because they are being compared to a value that is not lowercase (Trinity, Purple). Therefore the best score you could ever get is 1 for bronze.
if (question2.toLowerCase === 'Trinity')
if (question3.toLowerCase === 'Purple')
Chikanma Ibeh
1,396 PointsThank you, I made your corrections but it still does not work.
var question1 = prompt('What is my name?'); var score = 0 if (question1.toLowerCase === 'chikanma') { score += 1 }
var question2 = prompt('What school do you go to?'); if (question2.toLowerCase === 'trinity') { score += 1 }
var question3 = prompt('What is my favorite color?'); if (question3.toLowerCase === 'purple') { score += 1 }
if (score === 3) { alert("You have won a gold crown"); }
if (score === 2) { alert("You have won a silver crown"); }
if (score === 1 || score === 0) { alert("You have won a bronze crown"); }
Chikanma Ibeh
1,396 PointsChikanma Ibeh
1,396 PointsThank you, it worked!