Tell us what’s happening:
I just cannot figure out the problem in my code and I have tried checking my code but I cannot figure out. So anyone who is willing to tell me the problem.
**Your code so far**
function titleCase(str) {
let varAble = [];
let stringNew = "";
str.toLowerCase().split(" ").forEach(function nn (str){
varAble.push(str[0].toUpperCase() + str.slice(1));
});
for(let i = 0; i < varAble.length; i++){
stringNew = stringNew + " " + varAble[i];
}
return stringNew;
}
titleCase("I'm a little tea pot");
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
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/91.0.4472.77 Safari/537.36
Challenge: Title Case a Sentence
Link to the challenge: