Javascript String repeatStr(n)

Description

Javascript String repeatStr(n)



String.prototype.repeatStr = function(n){
    let str = '';
    for(let i = 0;i < n;i++){
        str += this;/* w  ww . j a  v  a2 s.  com*/
    }
    console.log(str)
}
'Hello'.repeatStr(3);//HelloHelloHello



PreviousNext

Related