Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Includes fix to program that provides output for both cases without an error.
# Ruby Getting Started with Programming
# A Codecademy Ruby (Thith Meanth War!) assignment
# Dr. Steven B. Combs, coding novice
print "Thtring pleathe: " # Print request for input
user_input = gets.chomp # Capture input and remove default extra line (.chomp)
user_input.downcase! # Change input to all lowercase and replace variable content
if user_input.include? "s" # If the input inlcludes an 's'
user_input.gsub!(/s/, "th") # Perform a global substitution of every 's' with 'th'
print "Your new sting is #{user_input}." # Print string including the new value
else # If input does not include an 's'
puts "Nothing to do!" # Print this line
end # End if loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.