Build a Title Case Converter - Build a Title Case Converter

Tell us what’s happening:

i not understand why the tests don’t pass.

Your code so far

const titleCase = (string) =>{
  let arr = string.split(" ");
  let result="";
  for (let word of arr) {
  result += word.charAt(0).toUpperCase()
  + word.slice(1).toLowerCase()+" "
  }
  return result;
}

console.log(titleCase("I'm a little tea pot"))  

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Title Case Converter - Build a Title Case Converter

if you take a look using console.log(JSON.stringify(titleCase("I'm a little tea pot"))), you should see that your string ends with a space

i add a .trim() behind result at the return statement and it’s worked