Here's a cool one-liner using regex
const titleCase = str => str.toLowerCase().replace(/\b\w/g, c => c.toUpperCase());