본문 바로가기

Algorithms

freeCodeCamp - 11. Title Case a Sentence [Basic Algorithm Scripting]

Title Case a Sentence

 

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence

 

www.freecodecamp.org

 

function titleCase(str) {
  let arr = str.split(' ')
  let anw = []
  for (let i of arr){
    anw.push(i[0].toUpperCase() + i.slice(1).toLowerCase())
  }
  let w = anw.join(' ')
  return w;
}

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