Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created July 31, 2015 09:39
Show Gist options
  • Select an option

  • Save JavaScript-Packer/0d006083a13919b075c2 to your computer and use it in GitHub Desktop.

Select an option

Save JavaScript-Packer/0d006083a13919b075c2 to your computer and use it in GitHub Desktop.
Repeat a string x times, choose the number of repeated times...
function repeat(e,r) {
return Array(r + 1).join(e);
}
//alert(repeat("WHAK.com!\n", 4));
@JavaScript-Packer

Copy link
Copy Markdown
Author

Use it without a function name:

alert(function(e,t){return Array(t+1).join(e)}("WHAK.com\n",4));

@JavaScript-Packer

Copy link
Copy Markdown
Author

Hack it down some more if you do not need a function:

alert(Array(4+1).join("WHAK.com\n"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment