repeatStringNumTimes
Repeat a given string `str` for `num` times. Return an empty string if `num` is not a positive number.
Examples
repeatStringNumTimes('*', 3) → '***'
repeatStringNumTimes('abc', 2) → 'abcabc'
Starter code
function repeatStringNumTimes(str, num) {
}
Complexity of the optimal solution
Time O(n*m), space O(n*m). The `repeat` method creates a new string of length `n * m`, where n is the length of `str` and m is `num`. This operation takes time and space proportional to the length of the final string.