Javascript String repeatify(num)
String.prototype.repeatify = String.prototype.repeatify || function(num){ "use strict";//from ww w . j av a 2 s. c om let newString = ""; while(num >0){ newString +=this; num--; } return newString; }; const b ="Brown"; console.log(b.repeatify(3));
String.prototype.repeatify = String.prototype.repeatify || function(num) { var str = ''; for(var i = 0; i < num; i++) { str += this.valueOf();//from www . j ava 2 s . com } return str; }; var numArg = parseInt(process.argv.slice(2)); console.log('hello'.repeatify(numArg));