In the FCC challenge “Title Case a Sentence”, my answer is delivering on the objectives but not passing the test. Please help me understand what’s wrong.
**Your code so far**
function cap(sentence) {
let words = sentence.split(" ")
for (let i=0; i < words.length; i++) {
words[i] = words[i].toLowerCase()
words[i] = words[i].replace(words[i].charAt(0), words[i].charAt(0).toUpperCase())
}
return words.join(" ")
}
let result = cap("I'm a little tea pot")
console.log(typeof(result))
console.log(result)
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
Challenge: Title Case a Sentence
Link to the challenge: