Title Case Function in JS

Saturday, February 29th 2020javascript

Ugh. It is still frustrating to capitalize first letter of each word in a string. Here's a copy-paste function (ES6):

const titleCase = word => (
    word.charAt(0).toUpperCase() + word.slice(1)
)

const titleCaseSentence = str => (
  str.split(" ").map(word => titleCase(word)).join(" ")
)