Tell us what’s happening:
I’m really stuck on this one. I don’t know how to target the first letter of each word. Please point me in the right direction
Your code so far
function titleCase(str) {
var arr = [];
//split string into array of separate words, convert to lower case
var broken = str.toLowerCase().split(" ");
//use for loop to iterate through each word in array
for (var i = 0; i < broken.length; i++) {
//replace first letter of each word with its uppercase equivalent
var re = broken[i].charAt(0);
arr.push(broken[i].replace(re , function() {
return re.toUpperCase;
}));
}
return arr;
}
titleCase("I'm a little tea pot");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; rv:59.0) Gecko/20100101 Firefox/59.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence