10 lines
195 B
JavaScript
10 lines
195 B
JavaScript
|
module.exports = function strRepeat(str, qty){
|
||
|
if (qty < 1) return '';
|
||
|
var result = '';
|
||
|
while (qty > 0) {
|
||
|
if (qty & 1) result += str;
|
||
|
qty >>= 1, str += str;
|
||
|
}
|
||
|
return result;
|
||
|
};
|