Javascript String repeatify(number)

Description

Javascript String repeatify(number)


String.prototype.repeatify=function(number){
    for(var i=1;i<number;i++){
        String.concat(String)
    }//from  w  ww.  j  a  v  a2  s  .  com
    return String;

}
console.log("hello".repeatify(3))

Javascript String repeatify(number)

(function() {// www.  ja v  a  2s.  co  m
'use strict'
String.prototype.repeatify = String.prototype.repeatify || function(number) {
    let string = ''
    for(let i = 0; i < number; i++) {
        string += this
    }
    return string
}
console.log('hello'.repeatify(3));
})()



PreviousNext

Related