Here's a better `stringRepeat` implementation:

```js
function stringRepeat(str, num) {
    var result = '';
    for (num |= 0; num > 0; num >>>= 1, str += str) {
        if (num & 1) {
            result += str;
        }
    }
    return result;
}
```