Skip to main content

repeatCharacters

A function that repeats each character of a given string by the specified repeat count and returns a new string.


Code

🔗 View source code


Interface

typescript
const repeatCharacters: (value: string, repeatCount: number) => string

Usage

typescript
import { repeatCharacters } from '@modern-kit/utils';

const str1 = 'A!B@C';
const repeatedStr1 = repeatCharacters(str1, 2); // 'AA!!BB@@CC'

const str2 = 'Hello';
const repeatedStr2 = repeatCharacters(str2, 3); // 'HHHeeelllooo'