Is it the right direction?

by the solutions i saw it’s totally not but i dont know any of the commands there

Your code so far


function titleCase(str) {
let words = str.split(' ');
for (let i = 0; i < words.length; i++) {
words[i].replace(/[A-Z]+/, /[a-z]+/);
words[i][0].replace(/[a-z]/, /[A-Z]/); 
}console.log(words)
}

titleCase("I'm a little tea pot");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Title Case a Sentence

Link to the challenge:

The second parameter of .replace() should not be a regular expression.

Thx, wondered why it doesnt work