times in String


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. String.prototype.times = function(num){
  2. return (num <= 0)? "": this.concat(this.times(--num));
  3. };
  4. alert("#".times(3));//show:###

Report this snippet


Comments


You need to login to view comments.