Tell us what’s happening:
Describe your issue in detail here.
I am so close in completing this exercise. The instruction is to convert the str into this new string Here Is My Handle Here Is My Spout
.
My code is returning exactly Here Is My Handle Here Is My Spout
but when I tried to console.log(result.split(" "))
it was returning with this [ '', 'Here', 'Is', 'My', 'Handle', 'Here', 'Is', 'My', 'Spout' ]
.
I am trying to get rid of the empty string in the index 0 but I can’t seem to remove it. I am also thinking that I am returning the arrays of the words
when I passed it in the result
instead of a string?
**Your code so far**
function titleCase(str) {
const words = str.toLowerCase().split(" ");
let result = "";
for (let word of words) {
let firstCap = word.replace(word[0], word[0].toUpperCase());
result = result + " " + firstCap;
}
console.log(result.split(" "))
return result;
}
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Challenge: Title Case a Sentence
Link to the challenge: