def titleize(string) string.split(\" \").map {|word| word.capitalize}.join(\" \") end
This titleizes every single word, but how do I capture cert
titleize("the matrix or titanic") def titleize(string) no_cap = ["and", "or", "the", "over", "to", "the", "a", "but"] string.split(" ").map { |word| no_cap.include?(word) ? word : word.capitalize }.join(" ") end
result:
"the Matrix or Titanic"