[javascript] How can I capitalize the first letter of each word in a string using JavaScript?

ECMAScript 6 version:

title
    .split(/ /g).map(word =>
        `${word.substring(0,1).toUpperCase()}${word.substring(1)}`)
    .join(" ");