Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 54x 54x 1x 1x 54x 3x 3x 54x | export function getInitial(firstName = '', lastName = '') { let initial = ''; if (firstName) { firstName = firstName.trim(); initial = firstName[0]; } if (lastName) { lastName = lastName.trim(); initial += initial ? lastName[0] : lastName.substring(0, 2); } return initial ? initial.toUpperCase() : initial; } export function getInitialByPattern(firstName, lastName, pattern) { if (pattern[0] === 'FIRST_NAME') { return getInitial(firstName, lastName); } return getInitial(lastName, firstName); } |