aboutsummaryrefslogtreecommitdiff
path: root/src/tools/numeronym-generator/numeronym-generator.service.ts
blob: 1c8447159daedd6cc2328a20fb0df9eb70186dc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
export { generateNumeronym };

function generateNumeronym(word: string): string {
  const wordLength = word.length;

  if (wordLength <= 3) {
    return word;
  }

  return `${word.at(0)}${wordLength - 2}${word.at(-1)}`;
}