Title Case a Sentence - Looked at Answer

After 8 hours of trying to figure this solution, I had to finally take a look at the solution, and at least try to understand it.

Can someone explain how var result was created? I’m mostly trying to understand function(val) what is val for as there is no input for it?

function titleCase(str) {
  var convertToArray = str.toLowerCase().split(" ");
  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");

The function gets called for each member of the array it is mapped on. Val ends up being that element’s value.