How to preserve the user's original capitalization


#1


https://codecademy.com/courses/ruby-beginner-en-JdNDe/0/8?curriculum_id=5059f8619189a5000201fbcb

I'm stuck on this additional challenge: Think about how you might preserve the user's original capitalization.

I can't yet reason through this one, using the code we've learned up until this point. And I really would like to stick with the code that's been taught so far, since I've noticed that some of the responses have been people recommending methods that haven't been reviewed yet.

Has anybody found a solution? Thanks a lot


print "Hello friend.  Give me some input.  Any input...  But make sure it contains an s, for pete'th thake..."
user_input = gets.chomp
user_input.downcase!

if user_input.include? "s" || "c"
    user_input.gsub!(/s/, "th")
    user_input.gsub!(/c/, "th")

    puts "Daffy Duck says, #{user_input}!"

elsif user_input.include? ""
    print "I'm thtill waiting! :)"

    
else
    print "Hello friend!  I noticed your statement doesn't contain an 's'.  Put one in there pleathe..."


#2

If you can't downcase the input, then instead of just having to replace s, you also have to replace S, am I missing something?

Also, note that the expression "s" || "c" is equivalent to "s"


#3

I'm not quite sure what your first sentence means. Can you extrapolate?

Also:

How is "s" || "c" equivalent to "s"? Can you explain your reasoning here?


#4

Test it in the console...

 > print "s" || "c"
 s

This is a logical expression fundamental. It might be an idea to do some review.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.