Javascript String repeatify(numTimes)
String.prototype.repeatify = function(numTimes) { var strArray = ""; for (var i = 0; i < numTimes; i++) { strArray += this;/*from www. j av a 2 s . c o m*/ } return strArray; }; console.log('hello'.repeatify(6)); String.prototype.repeatify = function (num) { var strArr = []; for(var i = 0; i < num; i++) { strArr.push(this); } return strArr; } console.log('hello'.repeatify(3));