Repeat a string multiple times.
repeat(string, count)
string (string) - The string to repeatcount (number) - Number of times to repeat (must be non-negative)String repeated the specified number of times
Basic repetition:
print(repeat("x", 5)) // "xxxxx"
print(repeat("ab", 3)) // "ababab"
Creating visual patterns:
print(repeat("-", 20)) // "--------------------"
print(repeat("*", 10)) // "**********"
Building output with repetition:
indent = repeat(" ", 4)
print(indent .. "item1")
print(indent .. "item2")
Zero and one repetitions:
print(repeat("x", 0)) // ""
print(repeat("hello", 1)) // "hello"