Tell us what’s happening:
Hi When I console log the tests the correct answers is being displayed but I’m not passing tests 4, 5, 6 , not sure if have just not used the code that is wanted or if there is something in the existing code
Your code so far
function titleCase(str) {
let first = str.toLowerCase();
let splits = first.split(" ");
let upper = [];
let result =[];
for (let i = 0; i < splits.length; i++) {
upper.push(splits[i][0].toUpperCase() + splits[i].substr(1) + " ");
result = upper;
}
return result.join('');
};
console.log(titleCase("sHoRt AnD sToUt"));
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
console.log(titleCase("I'm a little tea pot"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Challenge Information:
Build a Title Case Converter - Build a Title Case Converter