You’ll want to do something for each member of the array. You can do this through the .map() method, which accepts a function as an argument. Here is an example usage of .map()
A little too much detail proceeds below, if you get a bit stuck
In this case, you’ll want to take the first character, and make it an uppercase character; and take the rest of the characters (that’s a substring of the full element, by the way), and make them lowercase.
I’m getting so close to the answer. I’ve been working on this for hours now…LOL How do I make spaces within my string. I don’t want it to be array. I just want to add spaces betwen my words.
function titleCase(str) {
var newSentence = " ";
var test = " ";
var array = str.toLowerCase().split(’ ');
for(var i = 0; i < array.length; i++){
var upperCaseWord = array[i];
newSentence = upperCaseWord;
newSentence = newSentence.charAt(0).toUpperCase() + newSentence.slice(1);
test = test + newSentence;
TIP: You can assign back a new value to your array[i] element… after you capitalize the word. Then you can use .join() in your array to reconstruct the sentence.
Of course, going back to your original solution, you can just remove the trailing blank space before returning the value.