Returns an array with the elements of the iterable repeated a provided number of times.
Time complexity: O(n)
Space complexity: O(n)
The iterable to cycle
The number of times to repeat the elements of iterable
iterable
An array with the elements of iterable repeated times number of times
times
Iterable
[...cycle(['a', 'b'], 2)]; // ['a', 'b', 'a', 'b'] Copy
[...cycle(['a', 'b'], 2)]; // ['a', 'b', 'a', 'b']
Returns an array with the elements of the iterable repeated a provided number of times.
Time complexity: O(n)
Space complexity: O(n)