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 Solution

toUpperCase 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!"); }

3 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

It's toUpperCase(), don't forget to put the () there for the method call, in Ruby parentheses are optional sometimes; in JavaScript, () is never optional.

Thanks, I actually followed the video tutorial and that's how he did it. I will remember to do that next time.

Kevin Gilpin
Kevin Gilpin
4,054 Points

Yeah, I noticed after Question 1 he forgot to add the the parentheses on his methods. I thought it was going to be a test at the end to check for the bug, but nope. See even the experts make little mistakes.