Function repeat

  • Repeats the given string n times.

    Parameters

    • str: string

      The string to repeat.

    • n: number = 1

      The number of times to repeat the string.

    • Optional guard: any
      Optional

    Returns string

    Returns the repeated string.

    Since

    5.7.0

    Example

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

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

    repeat('abc', 0)
    // => ''