how can convert word to uppercase in this function

I want to declare a function that get a string and convert the first letter of every word to uppercase.

I wrote this code and it didn’t work correctly .

function titleCase(str) {
    let newStr = str.split(" ");
    for (let i = 0; i < newStr.length; i++) {
        newStr[i][0].toUpperCase()
    }
    return newStr.join(" ");

}

I think about another way but I didn’t find .
can anyone help me?