How can I capitalize certain letters in a string to make it so that only designated words are capitalized.
Must Past These Test: "barack obama" == "Barack Obama" & "the catcher in the rye" == "The Catcher in the Rye"
So far I have a method that will capitalize all words:
#Capitalizes the first title of every word.
def capitalize(words)
words.split(" ").map {|words| words.capitalize}.join(" ")
end
What are the most efficient next steps I could take to arrive at a solution? Thanks!
You could create a list of the word you don't want to capitalize and do
By the way, if you were using Rails and did not need to exclude specific words you could use
titleize
.