How can I capitalize the first letter of each word in a string using JavaScript?
You are not assigning your changes to the array again, so all your efforts are in vain. Try this: function titleCase(str) { var splitStr = str.toLowerCase().split(‘ ‘); for (var i = 0; i < splitStr.length; i++) { // You do not need to check if i is larger than splitStr length, as your for does … Read more