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


19,845 Points

Using toUpperCase() on variables

I am having trouble with this Javascript project that I am working on. I am making a quiz application and am having an issue with case sensitivity. I am trying to use the toUpperCase() method so that the answer that is provided by the user is not subject to case sensitivity but am having trouble with it. Any suggestions would be appreciated.

var ruby = prompt("What is the name of a programming language that is also the name of a gem?"); if (ruby === "ruby".toUpperCase()) { var numberCorrect = numberCorrect + 1; } else { var numberIncorrect = numberIncorrect + 1; }

1 Answer

Hey, you have to use the uppercase() method on your prompt, and not the value you are searching :

var ruby = prompt("...").toUpperCase();

if ( ruby === "RUBY")  // since the input is gonna be in uppercase !