Kindly help review my solutions to the algorithm challenges I’ve attempted so far.
First one I’ll be posting is ‘Title Case A Sentence’ because I was working on that when I made the decision.
function titleCase(str) {
var words = str.toLowerCase().split(' ');
words.forEach(function(w, index, arr){
firstChar = w.charAt(0);
edit = w.charAt().toUpperCase();
arr[index] = w.replace(firstChar, edit);
});
return words.join(' ');
}
titleCase("I'm a little tea pot");
Thanks!