FCC claims my working answer is wrong

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:

The first test states:

titleCase("I'm a little tea pot") should return a string.

So your function needs to be named accordingly.

1 Like

So I wasn’t clear there. You’ve renamed the function in the starter code that was named titleCase with a function that’s named cap. The test code is trying to call testCase for the tests but it doesn’t exist so the tests fail.