Tell us what’s happening:
what seems to be the issue? this is the error message
titleCase(“I’m a little tea pot”) should return I’m A Little Tea Pot.
titleCase(“sHoRt AnD sToUt”) should return Short And Stout.
titleCase(“HERE IS MY HANDLE HERE IS MY SPOUT”) should return Here Is My Handle Here Is My Spout.
Your code so far
function titleCase(str) {
let words = str.split(' ');
let updatedTitle = [];
for (let x in words) {
updatedTitle[x] = words[x].toLowerCase().replace(0, words[x].charAt(0).toUpperCase());
}
return updatedTitle.join(' ');
}
titleCase("I'm a little tea pot");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3223.0 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence