Tell us what’s happening:
Hello,
I have write below code for title Case a sentence using slice and concat function. But it is not working though output is coming as required.
Can someone help me in figuring out where i am mistaking?
Your code so far
function titleCase(str) {
str=str.toLowerCase().split(" ");
var newsentence="";
var newstr="";
for(var i=0; i<=str.length-1;i++)
{
newstr =str[i][0].toUpperCase()+str[i].slice(1)+(" ");
newsentence=newsentence.concat(newstr);
}
return newsentence;
}
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence