Write a function named repeat
that accepts an array ofString
s and an integer k
as parameters and that replaces each element with k
copies
of that element.
For example, if an array stores the values ["how", "are", "you?"]
before the function is called and k
is 4, it should store the values ["how", "how", "how", "how", "are", "are", "are", "are", "you?", "you?", "you?", "you?"]
after the function finishes executing.
If k
is 0 or negative, the array should be empty after the call. You may assume that the array passed is non-null.