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 trialJorge Vazquez
2,890 PointsOK i am not sure my issue!
My code previews a "0" for correct answers does matter what i do.
var correct=0; var answer1=prompt('How many players are in the Cleveland Cavaliers?'); if(answer1.toUpperCase() ==='fifteen players'){ correct+=1; } var answer2=prompt('Who is the best player on this team?'); if(answer2.toUpperCase() ==='Lebron James'){ correct+=1; } var answer3=prompt('Who did they beat on October 17th 2017?'); if(answer3.toUpperCase() ==='Boston Celtics'){ correct+=1; } var answer4=prompt('How may pionts did Lebron James score?'); if(answer4.toUpperCase() === 'Twenty nine points'){ correct+=1; }
document.write("<p>You got " + correct + " out of questions correct!</p>");
if (correct === 5){ document.write("<p><strong>You earned a Gold Crown.</strong></p>");
}else if(correct >= 3){
document.write("<p><strong>You earned a Silver Crown.</strong></p>");
}else if (correct >= 1){
document.write("<p><strong>You earned a Bronze Crown.</strong></p>");
}else {
document.write("<p><strong>You earned a No Crown.</strong></p>");
}
2 Answers
Steven Parker
231,271 PointsYou're converting the input to upper case, but then comparing it to strings that contain lower case — so it will never match.
But if you store your answers in all upper case you should be able to get a score.
Lomaloma Pepine
4,927 PointsIt should look like this one: just change assigned values to uppercase format... hope it helps
var correct=0;
var answer1=prompt('How many players are in the Cleveland Cavaliers?');
if(answer1.toUpperCase() ==='FIFTEEN PLAYERS')
{ correct+=1; }
var answer2=prompt('Who is the best player on this team?');
if(answer2.toUpperCase() ==='LEBRON JAMES')
{ correct+=1; }
var answer3=prompt('Who did they beat on October 17th 2017?');
if(answer3.toUpperCase() ==='BOSTON CELTICS')
{ correct+=1; }
var answer4=prompt('How may points did Lebron James score?');
if(answer4.toUpperCase() === 'TWENTY NINE POINTS')
{ correct+=1; }
document.write("<p>You got " + correct + " out of questions correct!</p>");
if (correct === 5){
document.write("<p><strong>You earned a Gold Crown.</strong></p>");
}else if(correct >= 3){
document.write("<p><strong>You earned a Silver Crown.</strong></p>");
}else if (correct >= 1){
document.write("<p><strong>You earned a Bronze Crown.</strong></p>");
}else {
document.write("<p><strong>You earned a No Crown.</strong></p>");
}