Created
January 7, 2016 10:22
-
-
Save krokrob/b9c220c0f1b6e53e7af6 to your computer and use it in GitHub Desktop.
This file contains 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
# Define a method that take a sentence and return the acronyme | |
# ex: | |
# puts acronymize("Gnu not unix") | |
# >"GNU" | |
def acronymize(sentence) | |
acronyme = "" | |
#Change string to array | |
sentence.split.each do |word| | |
acronyme += word[0].upcase | |
end | |
return acronyme | |
end | |
p acronymize("Federal bureau investigation") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment