Solution for "Title Case a Sentence"

The other solutions that didn’t use the replace() method seemed a bit cluttered.
I’m also learning by the curriculum , i think this is easier to understand at a glance.


function titleCase(str) {
  return str.split(' ')
  .map(a => {return a[0].toUpperCase() + a.slice(1).toLowerCase()})
  .join(' ');

titleCase("I'm a little tea pot");

Challange: Title Case A Sentence

1 Like