Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created January 7, 2016 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krokrob/b9c220c0f1b6e53e7af6 to your computer and use it in GitHub Desktop.
Save krokrob/b9c220c0f1b6e53e7af6 to your computer and use it in GitHub Desktop.
# 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