Nodejs String Repeat repeatifyString.prototype.repeatify || (times)

Here you can find the source of repeatifyString.prototype.repeatify || (times)

Method Source Code

String.prototype.repeatify = String.prototype.repeatify || function (times) {
   var str = '';

   for (var i = times; i--;) {
      console.log(i);/*from  w ww  .j a  v a2  s.c o m*/
      str += this;
   }

   return str;
};


console.log('1  '.repeatify(6))

Related

  1. repeatify(times)
    'use strict';
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
      var str = '';
      for (var i = 0; i < times; i++) {
        str += this;
      return str;
    };
    console.log('hello'.repeatify(3));
    ...
    
  2. repeatify(times)
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
        var string = '';
        for (var i = 0; i < times; i++) {
            string += this;
        return string;
    console.log('Hello'.repeatify(5));
    
  3. repeatify(times)
    String.prototype.repeatify = String.prototype.repeatify || function(times){
      var str = '';
      for(var i=0; i<times; i++){
        str +=this;
      return str;
    };
    console.log('hello'.repeatify(3));
    
  4. repeatify(times)
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
       var str = '';
       for (var i = 0; i < times; i++) {
          str += this;
       return str;
    };
    
  5. repeatify(timesToRepeat)
    String.prototype.repeatify = function(timesToRepeat) {
       var string = this;
       for (var i = 1; i < timesToRepeat; i++) {
          string += this;
       return string;
    };
    
  6. repeatifyString.prototype.repeatify || (num)
    String.prototype.repeatify = String.prototype.repeatify || function(num){
      "use strict";
      let newString = "";
      while(num >0){
        newString +=this;
        num--;
      return newString;
    };
    ...
    
  7. repeatifyString.prototype.repeatify || (number)
    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));
    
  8. repeatifyString.prototype.repeatify || (times)
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
       var str = '';
       for (var i = 0; i < times; i++) {
          str += this;
       return str;
    };
    console.log('hello'.repeatify(3));
    
  9. repeatifyString.prototype.repeatify || (times)
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
       let str = '';
       for (let i = 0; i < times; i++) {
          str += this;
       return str;
    };
    console.log('hello'.repeatify(3));