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 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,289 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......