Skip to content

Instantly share code, notes, and snippets.

@voxtex
Created August 28, 2013 19:52
Show Gist options
  • Save voxtex/6370444 to your computer and use it in GitHub Desktop.
Save voxtex/6370444 to your computer and use it in GitHub Desktop.
String.prototype.repeat = function(count) {
if (count < 1) return '';
var result = '', pattern = this.valueOf();
while (count > 0) {
if (count & 1) result += pattern;
count >>= 1, pattern += pattern;
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment