Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def acronomyze(string)
- # split our sentence on space
- string_split = string.split(" ")
- string_split.map do |word|
- word[0] # first letter of each string
- end
- # same as:
- # letters = []
- # string_split.each do |word|
- # letters << word[0]
- # end
- # join our array into our string
- string_together = string_split.join
- # make the string uppercase
- string_together.upcase
- end
- puts acronomyze("Away From Keyboard") == "AFK"
- puts acronomyze("Out of Offce") == "OOO"
- puts acronomyze("") == ""
- puts acronomyze("be right back") == "BRB"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement