Title case prolem

Tell us what’s happening:
pls can anyone help check what’s wrong with my code as it output the sentence all in uppercase.

Your code so far


function titleCase(str) {
var titleInitial = []
let strLower = str.toLowerCase().split('');
for( let i = 0; i < strLower.length; i++){
  titleInitial[i] = strLower[i].charAt(0).toUpperCase().concat(strLower[i].substr(1).toLowerCase()) ;
}
  


// strLower.toLowerCase();
return titleInitial.join("")
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.100 Safari/537.36.

Challenge: Title Case a Sentence

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence

You might want to check what this value you is that you are concatenating to the uppercase character starLower[i]. Remember, starLower[i] is a single character.

@RandellDawson thanks for the eye-opening hint! You made made me realize I’m uppercasing not single character but the first character of a word hence the way I applied the split() calls for correction. Now I can see the PROBLEM! My split() and join(). Once again a million thanks @RandellDawson! The corrected code now:
,
function titleCase(str) {
var titleInitial =
let strLower = str.toLowerCase().split(’ ');
console.log(strLower)
for( let i = 0; i < strLower.length; i++){
titleInitial[i] = strLower[i].charAt(0).toUpperCase() + strLower[i].substr(1).toLowerCase() ;
}

// strLower.toLowerCase();
return titleInitial.join(" ")
}

console.log(titleCase(“I’m a little tea pot”));
,