Convert the first letter of the word to a capital letter using JavaScript.


Convert the first letter of the word to a capital letter using JavaScript.

function toCapitalize(input){
  let split = input.split(" ")
  let change = split.map(val =>  val.charAt(0).toUpperCase() + val.slice(1))
  let joinWord = change.join(' ')
  console.log(joinWord)
}

let input = 'this is ok mareei ertierit ertrejtre'
toCapitalize(input)