Tell us what’s happening:
When I try on my own the code seems to work just fine but it is not passing tests.
What am I missing? What is wrong?
Your code so far
function titleCase(str) {
  let s = [];
  str = str.split(' ');
  
  // Iterating through str and adding first letter of each word to s array and capitalize.
  
  for(let i = 0; i < str.length; i++){
    s += str[i][0].toUpperCase();
// Iterating through rest of str and adding other letters to s array and lowercase.
    for(let j = 1; j < str[i].length; j++){
      s += str[i][j].toLowerCase();
    };
 // adding space beteween the words
    
    s += ' ';
  };
 
  return s;
}
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/76.0.3809.100 Safari/537.36.
Link to the challenge: