Hi everyone!
So I’m trying to solve the Title Case a Sentence problem and I’ve written some code for it, but it’s not outputting a joined string and I’m not sure why.
Here’s my code:
function titleCase(str) {
var stringArray = str.toLowerCase().split(" ");
for (var i = 0; i < stringArray.length; i++) {
return stringArray[i].charAt(0).toUpperCase() + stringArray[i].slice(1);
}
return stringArray.join();
}
titleCase("I'm a little tea pot");
Thank you for your help!