Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Aaron HARPT
Aaron HARPT
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 !
{
}