Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Created January 23, 2015 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradoyler/60e2c8a926d04cd0ef17 to your computer and use it in GitHub Desktop.
Save bradoyler/60e2c8a926d04cd0ef17 to your computer and use it in GitHub Desktop.
repeat a string
String.prototype.repeat = function(n) {
return new Array(1 + (n || 0)).join(this);
}
console.log("ha".repeat(5)); // hahahahaha
// this is built-in to ES6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment