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 trialRuben Lindskog
1,008 Pointscan't get toUpperCase to work
I'm trying to ask a question with different strings as the correct answer. I'm trying to avoid people getting it wrong because they didn't use uppercase lettering. var questionThree = prompt('Name a country in Scandinavia'); var questionThreeAnswer = questionThree.toUpperCase; alert( questionThreeAnswer ); The variable doesn't give me the answer in uppercase but instead says this "function toUpperCase() { [native code] }". What am i doing wrong?
2 Answers
Steven Parker
231,271 PointsSince "toUpperCase" is a function, the name must be followed by parentheses to invoke it even if no arguments are being passed in them.
var questionThreeAnswer = questionThree.toUpperCase(); // <- note the added ()'s
Ruben Lindskog
1,008 Pointsthank you so much!
Ruben Lindskog
1,008 PointsRuben Lindskog
1,008 Pointsvar stringToShout = prompt("What should I shout?"); var shout = stringToShout.toUpperCase(); shout += "!!!"; alert(shout); this is from a previous workshop and i don't see how it works and mine don't