Tell us what’s happening:
I have used two for loop’s instead of one for loop and other in-built functions like the solutions suggest. Does it not get accepted because of inefficiency maybe?
**Your code so far**
function titleCase(str) {
let strArr = str.split(" ");
let finalStr = "";
for (let i = 0; i < strArr.length; i++) {
let tempArr = strArr[i].split("");
var tempStr= "";
for (let j = 0; j < tempArr.length; j++) {
if (j == 0) {
tempStr += tempArr[j].toUpperCase();
}
else tempStr +=tempArr[j].toLowerCase();
}
finalStr += tempStr + " ";
}
return finalStr;
}
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/92.0.4515.131 Safari/537.36
Challenge: Title Case a Sentence
Link to the challenge: