yannb9
7/25/2018 - 6:47 AM

Capitalize

Capitalize first letter of words of a string

function capitalizeWords(str) {
  var splitStr = str.split(' ');
  for(var i in splitStr){
    splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
  }
  return splitStr.join(' ');
}