Let - In | JavaScript

I missed the chapter where he dealt with this type of cred assignment, I can’t understand what that means

let st in newTitle

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

thanks

The operation isn’t really referred to as let-in but rather for...in. What we’re saying is “for each value in this array (newTitle), assign the value to the variable st and do this loop”. You can read more about it https://devdocs.io/javascript/statements/for...in, and in the meantime I’ll see if I can find the lesson that references this.

2 Likes

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