Creates an acronym from a string by taking the first letter of each word and capitalizing it.
Contributed by @itsbrunodev
function acronym(str) {
return str
.split(/\s+/)
.map(word => word[0].toUpperCase())
.join("")
.slice(0, 3);
}
acronym("john doe"); // "JD"