SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top