Tell us what’s happening:
Please review my code
Your code so far
function titleCase(str) {
let setText = str.split(" ");
let mapText = setText.map(x => x.toUpperCase());
for (let i = 0; i < mapText.length; i++) {
let laterText = mapText[i].slice(1);
setText[i] = mapText[i][0] + laterText.toLowerCase();
}
return setText.join(" ");
}
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/105.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Title Case a Sentence
Link to the challenge: