Title Case a Sentence - question

I couldn’t solve this on my own and looked at the solutions forum. One member posted this solution which I can understand the best out of all of them. However one thing I don’t fully get is why in the for loop the final expression is i+=1 and not i++?

function titleCase(str) {
  var strArray = str.toLowerCase().split(" ");
  for (var i=0; i<strArray.length; i+=1) {
    strArray[i] = strArray[i].charAt(0).toUpperCase() + strArray[i].substring(1);
  return strArray.join(" "); 
titleCase("sHoRt AnD sToUt");

I am referring to this lesson:

no specific reason, they do the same thing

1 Like