@mazzaroth808 wrote:
MY SOLUTION
titleCase(Str) { var oldArr = str.toLowerCase().split(' '); var newArr = []; for (var i in oldArr) { var newWord = oldArr[i][0].toUpperCase() + oldArr[i].slice(1); newArr.push(newWord); } return newArr.join(' '); }
there’s no need for:
for (var i = 0; i < oldArr.length; i++) {
}because:
for (var i in oldArr) {
}will loop through the entire length of oldArr without the need of a loop counter.