Say you built an app and wanted to show a user’s initial in an avatar, to do so you KISS:

const avatar = displayName[0]
const displayName = "Nadav"

One day, a user decides to make their display name:
const displayName = "🇨🇦 Mike"
or const displayName = "👍🏽 Dave"
or const displayName = "👨‍👩‍👧‍👦 The Smiths"
or maybe const displayName = "🤷 idk"

*slack bloop* avatars are broken, pls fix.

const avatar = [...displayName][0]

Closer, but notice how the flag split into a letter, the thumbs up lost its skin tone, and the family is just a man now? Hold that thought.

const seg = new Intl.Segmenter('en', { granularity: 'grapheme' })
const avatar = [...seg.segment(displayName)].map(x => x.segment)[0]

Found a mistake? Submit a PR!