Acronym

Creates an acronym from a string by taking the first letter of each word and capitalizing it.

Contributed by @itsbrunodev

javascript
function acronym(str) {
  return str
    .split(/\s+/)
    .map(word => word[0].toUpperCase())
    .join("")
    .slice(0, 3);
}
javascript
acronym("john doe"); // "JD"
GitHubEdit on GitHub