I'm not sure if my approach to solving this problem is correct:
function capitalizeFirstLetter (string) {
let stringArray = string.split(' ');
for (let i = 0; i < stringArray.length; i++) {
let firstLetter = stringArray[i].charAt(0);
let firstLetterCap = firstLetter.toUpperCase();
}
return stringArray.join(' ');
}
console.log(capitalizeFirstLetter('cat on the mat'));
It appears that the function just returns the original string without capitalizing anything.