Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Created October 9, 2013 01:03
Show Gist options
  • Save bjhaid/6894506 to your computer and use it in GitHub Desktop.
Save bjhaid/6894506 to your computer and use it in GitHub Desktop.
Wednesday Kata
Complete the method so that it formats the words into a single comma separated value. The last word should be separated by the word 'and' instead of a comma. The method takes in an array of strings and returns a single formatted string. Empty string values should be ignored. Empty arrays or null/nil values being passed into the method should result in an empty string being returned.
format_words(['ninja', 'samurai', 'ronin']) # should return "ninja, samurai and ronin"
format_words(['ninja', '', 'ronin']) # should return "ninja and ronin"
format_words([]) # should return ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment