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 JavaScript Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

Mayank Munjal
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mayank Munjal
Front End Web Development Techdegree Graduate 18,120 Points

How to get Ruby as a result instead of all uppercase RUBY ?

I was wondering people will either write Ruby or ruby in most cases, is it possible that ruby gets converted to Ruby instead of RUBY

4 Answers

Joshua Michaels
Joshua Michaels
7,306 Points

Not exactly what you asked for but this is how I solved it:

if ( answer === 'Ruby' || 'ruby' ) ...but as brendon pointed out that doesn't catch all capitalizations so the toUpperCase() method is the best.

Jesus Mendoza
Jesus Mendoza
23,275 Points

Hey Mayank

First you need to use slice to take out the r and store it into a variable, then uppercase it and lastly you concatenate it to the rest of the string slicing out the first lowercase r.

brendon fletcher
brendon fletcher
746 Points

Unless you are wanting to store the user input as value in some manner than the above solution, although 100% correct, would be more work than what is called for. Simply adding the toUpperCase method (as shown) would be the easiest solution to let the program function accordingly regardless of the capitalization or lack thereof. All variations of "ruby" would work, i.e. "RuBy; rUbY; rUBY" and so forth.

WHOA......