Skip to content

Instantly share code, notes, and snippets.

@DonSchado
Created October 26, 2011 17:48
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 DonSchado/1317131 to your computer and use it in GitHub Desktop.
Save DonSchado/1317131 to your computer and use it in GitHub Desktop.
Given a sentence containing multiple words, find the frequency of a given word in that sentence.
def find_frequency(sentence, word)
sentence.downcase.split.count(word.downcase)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment