Skip to content

Instantly share code, notes, and snippets.

@Amli
Created February 11, 2014 12:49
Show Gist options
  • Save Amli/8934260 to your computer and use it in GitHub Desktop.
Save Amli/8934260 to your computer and use it in GitHub Desktop.
fastest repeat string n times
function repeat(str, n) {
if (n < 1) return '';
var result = '';
m = str.length
while (n > 0) {
if (n & 1) result += str;
n >>= 1;
str += str;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment