I can write this code in a simpler way but I want to write it as a function based code. I am looking to change the starting letter of each word in a string to uppercase.Please help!!
function convertuc(str) {
let arr = str.toLowerCase().split(" ");
for (let s of arr){
let arr2 = arr.map(s.charAt(0).toUpperCase() + s.substring(1)).join(" ");
}
return arr2
};
console.log(convertuc("convert the first letter to upper case")); // Test//