Ruby function to capitalize all words in a string
You could make it a one liner. If you want to get fancy checkout Rail's implementation https://apidock.com/rails/v5.2.3/ActiveSupport/Inflector/titleize

str.split.map(&amp;:capitalize).join(' ')