0

I'm writing an algorithm to capitalize the first letters of words within a string. I think the logic I've written is correct - but I don't know how to return the newly-capitalized word. Any suggestions? Code as follows:

    const upperCase = (str) => {

     let splitString = str.split(' ')
     let newArr = []


      for(let i=0; i<splitString.length; i++) {
        for (let j=0; j<splitString[i]; j++) {
          let capLet = splitString[i]
          capLet === splitString[0] ? capLet.toUpperCase() : null   // not sure what to do after this!
        }  
      }
    }
Josh Simon
  • 159
  • 1
  • 10
  • 27

0 Answers0