Capitalizing the first letter of each string in an arrary

I couldn’t get my solution to work because I couldn’t get it to select the first letter of each string in the array. I just kept getting errors. I gave in and looked at the solution which has left me even more confused and exasperated.

How does this thing iterate through the array?

How does it select the first letter of each string? It looks to me like it just selects the entire word at the first index.

I know I clearly have a knowledge gap about something fundamental but I didn’t recognize large parts of any of the solutions from the tutorials and I feel as though I have been learning to run and now asked to cycle a bike.

   **Your code so far**

function titleCase(str) {
var convertToArray = str.toLowerCase().split(" ");
console.log(convertToArray)
 var result = convertToArray.map(function(val) {
   return val.replace(val.charAt(0), val.charAt(0).toUpperCase());
 });
 return result.join(" ");

}

titleCase("I'm a little tea pot");
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53

Challenge: Title Case a Sentence

Link to the challenge:

its easier to help you, if we see your solution and see where your gaps are, what you are trying to do wrong.
In the solution you show, there are few methods used, split, join, map, replace, charAt. To understand how the solution work, you should understand each of those methods. Which one of them causes you trouble? Very often, when i need a job done, i look up google and pick up suitable method to handle the job. Its a good way to see methods in action, and where they have good use. Not always ill come right away with the best method at hand. In the end, you could even avoid using methods, but go to basic JS functions. You can for example make a code which looks for blank spaces in the string and capitalize letters after those spaces.
Since strings are immutable(you cant pick parts of them and change them, like you can with arrays, you need to change the whole value, or split the string into separate values), its easier to convert the string itno an array, or use methods like regex, replace, charAt, substring etc.
In the example solution, the function first converts the entire string into lower case, for convenience and splits it into array of words. Than it goes thru every word(map) and makes sure each word starts with a capital letter. It utilizes replace for that purpose; with charAt(0), it targets the first letter of the word and replaces it as upper case. In the end the array is joined back to a sentence.