Title Case a Sentence(charAt used)


Tell us what’s happening:

Almost there! I didn’t want to dig for the answer. I was hoping I could get a hand as to why mine is wrong…I’ve scoured hi and low…

Your code so far

function titleCase(str) {
  word = str.split(" ").charAt(0).toUpperCase.join("");
  return word;

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

Your browser information:

Link to the challenge:


charAt is a function that operates on a String. while split is a String operation which returned an Array.
Using a String function on an Array would not work.
Hope this helps.


It was like this last time I attempted JavaScript. I think I’m getting it, and I hit a wall…


Don’t hit the wall… it hurts :smiley:

you might want to iterates through the Array that you created with split.

str // str comes with "I'm a little tea pot"
var splittedString = str.split(" ") // this will split the str into splitted String
splittedString // content is ["I'm", "a", "little", "tea", "pot"]

since splittedString is an Array now… you would need to uppercase every element of it.

You are right … you are almost there… just need to perform the toUpperCase function inside a loop.


Thanks! The little wins have been great. It just feels like it’s light years away sometimes…