Capitalizing the start of array's strings

Can someone help me to see what I am not seeing here please:

function titleCase(str) {

  let myRegex = /\S+/gi;
  let myArray = str.match(myRegex);

  console.log(myArray);  //[ 'I\'m', 'a', 'little', 'tea', 'pot' ]
  

  for (let i=0; i<myArray.length; i++){
    myArray[i].charAt(0).toUpperCase();
  }

  console.log(myArray); //doesn't capitalize the start letter of every array's strings, why? 

}

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

Strings are immutable. This means you can not directly change individual characters of an existing string. You can however build a new string by concatenating the changes you want.

1 Like

It is a primitive, right! Thank you very much!