I dont understand how this for loop is calling itself

function titleCase(str) {
  const newTitle = str.split(" ");
  const updatedTitle = [];
for (let st in newTitle) {
    updatedTitle[st] = newTitle[st]
      .toLowerCase()
      .replace(newTitle[st].charAt(0), newTitle[st].charAt(0).toUpperCase());
  }
  return updatedTitle.join(" ");
}

Can someone explain the syntax in the for loop here? The only syntax I understand is the ([initalize], [condition], [resolution]).

It’s a for in loop, which loops over properties of an object. In addition to that, there’s also a for of loop, which loops over the values in an iterable (usually an array). These both come up somewhere in the fCC curriculum.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.