Capitalise the first letter of a word in a sentence using javascript


//Capitalise the first letter of a word in a sentence

 const capitaliseFirstLetter = (fullStr) => {
         let strArray = fullStr.split(" ");
         for (let i = 0; i < strArray.length; i++) {
             strArray[i] = strArray[i].substr(0, 1).toUpperCase() + strArray[i].substr(1);
         }
     return strArray.join(" ");
 }

 console.log(capitaliseFirstLetter("hello world.")); //Hello World.