getInitials

getInitials

Returns initial characters of spaces separated words

Import

import { getInitials } from '@fullstacksjs/toolbox';

Signature

function getInitials(name: string, fallback: string = '?'): string {}

Examples

getInitials('')                  // '?'
getInitials(' ', 'FB')           // 'FB'
getInitials('frontend')          // 'F'
getInitials('frontend monsters') // 'FM'
getInitials('2')                 // '2'
getInitials('1 2 3 4')           // '1234'
getInitials('x @# % * ))__() 1') // 'X@%*)1'
getInitials('frontend monster rides a dinosaur in office') // 'FMRADIO'