Repeats the given string n times.

Syntax

TypeScript
import { repeat } from '@opentf/std';

repeat(str: string, n = 1): string;

n must be a non-negative finite integer.

Examples

TypeScript
repeat('*', 3) //=> '***'

repeat('abc', 2) //=> 'abcabc'

repeat('abc', 0) //=> ''
Last updated on
Edit this page