Tell us what’s happening:
Basic Algorithm Scripting: Title Case a Sentence
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
For the purpose of this exercise, you should also capitalize connecting words like “the” and “of”.
Your code so far
Help me with the code why its not running
function titleCase(str) {
str=str.toLowerCase();
str=str.split(" ");
let k="";
for(let i=0;i<str.length;i++)
{
let j = str[i].split("");
j[0]=j[0].toUpperCase();
j=j.join("");
k+=j+" ";
}
console.log(k);
return k;
}
titleCase("sHoRt AnD sToUt");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
.
Challenge: Title Case a Sentence
Link to the challenge: