Tell us what’s happening:
Can anyone please help me figure out why the below LOCs are not accepted?
Just to be sure, the outcomes are, I think, what is expected.
**Your code so far**
function titleCase(str) {
const arrOfStrings = str.split(" ");
let casingWords;
let cased = "";
for (let i of arrOfStrings) {
// uppercase the first index and lowercase the rest for each words
casingWords = i[0].toUpperCase() + i.slice(1).toLowerCase();
cased += casingWords + " ";
}
return cased;
}
console.log(titleCase("I'm a little tea pot"));
//I'm A Little Tea Pot
console.log(titleCase("sHoRt AnD sToUt"));
//Short And Stout
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
//Here Is My Handle Here Is My Spout
Please find the repo here: Github Repo
Challenge: Title Case a Sentence
Link to the challenge: