Here’s my code it works just fine, but if we pass it a string “I’m a little tea pot”, it returns “I’M A Little Tea Pot”, not “I’m A Little Tea Pot”.
I’d appreciate if anyone could help me
function titleCase(str) {
let lowerStr = str.toLowerCase();
let newStr = lowerStr.replace(/\b\w/g, c => c.toUpperCase());
return newStr;
}