Title Case a Sentence - solution

Title Case a Sentence - solution
0

#1

Hey guys!

I just wanted to share a different way to solve this challenge… Hope it would help someone!

function titleCase(str) {

  let words = str.toLowerCase().split(' ')
 for (let i = 0; i < words.length; i++) {
   let letters = words[i].split('');
   letters[0] = letters[0].toUpperCase();
   words[i] = letters.join('');


 } return words.join('      console.log(words); ')


}
  titleCase("I'm a little tea pot");



**Link to the challenge:**
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence