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 trialDan McCarty
10,082 PointstoUpperCase not working
My code works fine until I add in the toUpperCase method. Can you let me know why?
var q1 = prompt("What is Elvis's last name?"); var q2 = prompt("Who was god of the Trojans?"); var q3 = prompt("Who sung feel the steel?"); var q4 = prompt("What is 5 minus 3?"); //q4 = parseInt(q4); var q5 = prompt("To be or not to be, that is the _?");
var answerTotal = 0;
if (q1.toUpperCase === "PRESLEY") { answerTotal += 1; } if (q2.toUpperCase === "APOLLO") { answerTotal += 1; } if (q3.toUpperCase === "STEEL PANTHER") { answerTotal += 1; } if (parseInt(q4) === 2) { answerTotal += 1; } if (q5.toUpperCase === "QUESTION") { answerTotal += 1; }
if (answerTotal === 5) { document.write("Congratulations you have recieved the gold crown!"); } else if (answerTotal >= 3) { document.write("Congratulations you have recieved the silver crown!"); } else if (answerTotal >= 1) { document.write("Congratulations you have recieved the bronze crown!"); } else { document.write("Sorry you missed all the answers!"); }
2 Answers
Abdul hamid Achik Lopez
15,659 Pointsyou forgot to call the function man
string.toUpperCase()
you did:
string.toUpperCase
Joshua Asher
3,775 PointsThanks Abdul for the answer. I was having the same issue too. ;)