So I wrote:
function titleCase(str) {
var words = str.split(' ');
words = words.map(word => word.toLowerCase())
for (var i=0; i<words.length; i++) {
}
console.log(words)
return str;
}
Hint 1 states:
- You should start by splitting the string into an array of words.
- Split the sentence.
Which I did with the first line.
Then Hint 2 says:
- You should make the word lowercase before making the first letter uppercase.
- Use replace method on each word to capitalize the first letter of each word.
I did the first bullet point with map but replace seems to only work for strings not arrays.