Created
September 30, 2013 22:07
-
-
Save ahimmelstoss/6771023 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reverse_each_word(sentence) | |
sentence_array = sentence.split(" ") | |
sentence_array.collect {|word| word.reverse}.join(" ") | |
end | |
puts reverse_each_word("Hello there, and how are you?") | |
#=> "olleH ,ereht dna woh era ?uoy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment