please can anyone help me explain
the role of
the for…in loop in this code .
i dont really understand how the loop works on things challenge.
please i need enlightenment.
Your code so far
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(" ");
}
console.log(titleCase("I'm a little tea pot"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.54
Challenge: Basic Algorithm Scripting - Title Case a Sentence
Link to the challenge: