JavaScript: Repeat string
I wanted to build a string of 20 repeating characters. This function makes it really easy:
String.prototype.repeat = function(num) {
return new Array(num + 1).join( this );
}
Now I can write:
var separator = "=".repeat(20);