Been Going at this one awhile… My logic, after splitting the sentence and lower-casing it, was to isolate the first letters, capitalize them, then go get the rest of the word and put the sentence back together… I finally got all the proper letters capitalized, and added on the rest of the words… But there is a space between every. single. character. This is like a bad joke!! So close!!! oof…
console.log(str) gives me — “I ’ m A L i t t l e T e a P o t”
Gonna have to come at this again tomorrw, but any insight advice would be much appreciated!!!
**Your code so far**
function titleCase(str) {
str = str.toLowerCase().split(" ");
var firstLetters = [];
for(let i = 0; i < str.length; i++) {
firstLetters.push(str[i][0].toUpperCase())
for(let j = 1; j < str[i].length; j++)
firstLetters.push(str[i][j]);
}
str = firstLetters.join(' ')
console.log(str)
return str;
}
titleCase("I'm a little tea pot");
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.
Sleepy over here too, used mozilla page looked up map method used the built in map method on it, its amazing what a good night sleep will do, your brain will keep working on it all night!
If you conditionally push a space character at the end of your nested for loop and have your join method using '' it’ll pass. The condition should be such that it does push a space on the last word.