Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. def acronomyze(string)
  2. # split our sentence on space
  3. string_split = string.split(" ")
  4.  
  5. string_split.map do |word|
  6. word[0] # first letter of each string
  7. end
  8.  
  9. # same as:
  10. # letters = []
  11.  
  12. # string_split.each do |word|
  13. # letters << word[0]
  14. # end
  15.  
  16. # join our array into our string
  17. string_together = string_split.join
  18.  
  19. # make the string uppercase
  20. string_together.upcase
  21. end
  22.  
  23. puts acronomyze("Away From Keyboard") == "AFK"
  24. puts acronomyze("Out of Offce") == "OOO"
  25. puts acronomyze("") == ""
  26. puts acronomyze("be right back") == "BRB"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement