Learn
Great! Now we’ve got our output, but as you can see, we haven’t used string methods to properly capitalize everything yet.
print "This is my question?" answer = gets.chomp answer2 = answer.capitalize answer.capitalize!
- First we introduce one new method,
capitalize
, here. It capitalizes the first letter of a string and makes the rest of the letters lower case. We assign the result toanswer2
- The next line might look a little strange, we don’t assign the result of
capitalize
to a variable. Instead you might notice the!
at the end ofcapitalize
. This modifies the value contained within the variableanswer
itself. The next time you use the variableanswer
you will get the results ofanswer.capitalize
Instructions
1.
After each variable assignment: first_name
, last_name
, and city
add the .capitalize!
method
For state
use the .upcase!
method
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.