Title Case a Sentence - Why won't this work?

Title Case a Sentence - Why won't this work?
0.0 0

#1

Hey everyone,

I’m not really sure why I can’t pass the Title Case a Sentence algorithm with the following code, it passes all of the tests in the console. Any thoughts?

var titleCase = function titleCase(str) {
  var splitSentence = str.toLowerCase().split(' ');
  var titleCasedArray = splitSentence.map(function (el) {
    return el.charAt(0).toUpperCase() + el.substring(1, el.length);
  });
  var result = titleCasedArray.join(' ');
  return result;
};

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

#2

I tested your code and it passed fine. You may just need to refresh the page and run the test again. If that does not work, try closing the browser and coming back in to run the tests.


#3

Yes! Thought so. Thanks Randell