Tell us what’s happening:
Describe your issue in detail here.
I don’t know why pass this code.
Your code so far
function titleCase(str) {
let arr=str.split(" ");
let micadena="";
//arr.forEach(element => console.log(element));
arr.forEach(element => {
let primera=element[0].toUpperCase();
let resto="";
for (let i=1;i<element.length;i++){
resto=resto+element[i].toLowerCase();
}
micadena=micadena+primera+resto+" ";
});
str=micadena;
return str;
}
console.log(titleCase("I'm a little tea pot"));
console.log(titleCase("sHoRt AnD sToUt"));
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Title Case a Sentence
Link to the challenge: