Title Case a Sentence3

Title Case a Sentence3
0.0 0

#1

Tell us what’s happening:
I dont seem to understand the error

Your code so far

function titleCase(str) {
  var wrd=str.toLowerCase().split(" ");
  for (var x=0; x<wrd.length;x++){
    wrd[x][0]=wrd[x][0].toUpperCase();
  }
  str= wrd.join(" ");
  return str;
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15.

Link to the challenge:


#2

You cannot mutate a string in Javascript.
wrd[x][0]=wrd[x][0].toUpperCase();
This line of code does not change wrd[x] because the string stored in wrd[x] cannot be changed.

You can create a new string from parts and then assign it to wrd[x] though.
wrd[x] = wrd[x][0].toUpperCase() + some other stuff