Tell us what’s happening:
Hello Everyone,
looks like i’m completely suck on this algorithm. I was able to split it to an array and changed everything to lowercase but i’m completely suck at this point. I did a loop but it only returns the first letter of the first word as upper case. Any help will be much appreciated.
Thanks,
Ray
Your code so far
function titleCase(str) {
var array = str.toLowerCase().split(" ");
var upperCase = [];
for (var i=0;i<array.length; i++){
upperCase = array[i][0].toUpperCase();
return upperCase;
}
}
titleCase("I'm a little tea pot");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence