Function repeat

  • Repeats the given string n times.

    Parameters

    • Optionalstring: string

      The string to repeat.

    • Optionaln: number

      The number of times to repeat the string.

    Returns string

    Returns the repeated string.

    3.0.0

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

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

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