2008-01-07から1日間の記事一覧

文字列繰り返し

String.prototype.repeat = function(n, sep) { this.n = this.n + 1 || 1 if(this.n >= n) return this; return this + (sep || "") + arguments.callee.call(this, n, sep); } print("hoge".repeat(3, '+')) // hoge+hoge+hoge print("fuga".repeat(4, '-'…