Here is what I was able to come up with for my solution using splice.
function titleCase(str) {
var lowerCase = str.toLowerCase();
var wordArray = lowerCase.split(" ");
var newWord = [];
var newLetter = [];
var finalWord = “”;
for (i = 0; i < wordArray.length; i++){
newLetter += wordArray[i][0].toUpperCase();
newWord += wordArray[i].replace(wordArray[i][0], newLetter[i]) + ’ ';
}
newWord = newWord.split(" “);
newWord.splice(-1,1);
console.log(newWord);
finalWord = newWord.join(” ");
return finalWord;
}
titleCase(“I’m a little tea pot”);