As a beginner in the world of javascript, I am just starting to dip my toes into it.
In the past, I have used join() without any issues, but now I am facing a problem where this join is returning an empty string.
Upon inspecting myArray, the data seems to be properly formatted.
Any assistance on resolving this issue would be greatly appreciated. Thank you!
function titleCase(str) {
var splitArray = str.split(" ");
var myArray = [];
var joinArray = myArray.join(' ');
for (var i in splitArray) {
myArray.push(splitArray[i].charAt(0).toUpperCase() + splitArray[i].slice(1).toLowerCase());
}
return joinArray;
}
titleCase("capitalize the first letter of each word in this string");