Skip to content

Instantly share code, notes, and snippets.

@argshook
Created November 14, 2013 13:23
Repeat string as many times as you need without any loops.
String.prototype.repeat = function(times) {
return (new Array(times + 1)).join(this);
};
var str = "1".repeat(3);
console.log(str); // 111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment