strRepeat.js 195 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 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; };