Tell us what’s happening:
I’m not sure what to do next. I can get the first character of each word uppercase, but now I don’t know how to join the string back together with the uppercase letter. I’ll continue working and update if I get it.
Your code so far
function titleCase(str) {
var a;
a = str.toLowerCase().split(' '); //makes the string lowercase and splits it up
for (i=0; i<a.length; i++) { //goes through each word
a[i] = a[i].charAt(0).toUpperCase() + a[i].slice(1);
}
return a.join(" ");
}
titleCase("I'm a little tea pot");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence