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

RSS Icon Subscribe to comments

You need to login to post a comment.