Tell us what’s happening:
I’m stuck on this exercise. My code doesn’t work. I get a Type Error, and the statement that the contents of my for loop isn’t a function.
Can someone tell me what’s wrong here?

Your code so far

function titleCase(str) {
  var textSplit = str.split();
  var textArray = [];
  for (var i = 0; i < textSplit.length; i++) {
    textArray[i] = textSplit[i].toLowerCase().replaceAt(0, textSplit[i].charAt(0).toUpperCase()); 

  return textArray.join(' ');

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36.

Link to the challenge:

Method replaceAt doesn’t exist in the string prototype.


  • You have used split wrong, you need to pass in an argument with a value of where to split.
  • Try to use substr method to solve this problem.

You need to call the split function with a delimiter, similar to the way you used the join function in your return statement.

Thanks! Now I see the problem.