Title Case a Sentence in Basic Algorithm Section

Tell us what’s happening:
I need help tackling this problem. I am having a lot of trouble with the basic algorithms

Your code so far


String.prototype.replaceAt = function(index, character) {
    return this.substr(0, index) + character + this.substr(index+character.length);
};

function titleCase(str) {
    var newTitle = str.split(' ');
    var updatedTitle = [];
    for (var st in newTitle) {
        updatedTitle[st] = newTitle[st].toLowerCase().replaceAt(0, newTitle[st].charAt(0).toUpperCase());
    }
    return updatedTitle.join(' ');
}

titleCase("I'm a little tea pot");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence

Your solution is passing for me - although I think writing a prototype method is overkill. Rather than use your replaceAt, I would just have done that on the line in the for loop, get the first letter and capitalize it and then add the rest of the string to it.

But your solution does work. If you can’t get it to work, try rebooting, clearing your browser cache, try a different browser. If none of those work, just move on.