repeat
arrayRepeats a value n times, creating an array
Syntax
repeat(value, count) Parameters
value (any) The value to repeat
count (number) The number of times to repeat the value
Returns
array An array containing the value repeated count times
Examples
Input:
repeat("x", 5) Output:
["x", "x", "x", "x", "x"] Input:
repeat(0, 3) Output:
[0, 0, 0] The repeat() function creates an array by repeating a specified value a given number of times.
Usage
This function is useful for initializing arrays with default values, creating patterns, or generating sequences of identical elements.