Tell us what’s happening:
Describe your issue in detail here.
I used console.log() command to verify my code, it can output the string that convert each first letter to uppercase, but it still not pass, anything wrong with my code?
Your code so far
function titleCase(str) {
let arr=str.split(" ");
let stry="";
for(let i=0;i<arr.length;i++)
{
arr[i]=arr[i][0].toUpperCase()+arr[i].slice(1,arr[i].length);
stry+=arr[i]+" ";
}
return stry;
}
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/105.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Title Case a Sentence
Link to the challenge: