Nodejs String Repeat repeatify(timesToRepeat)

Here you can find the source of repeatify(timesToRepeat)

Method Source Code

String.prototype.repeatify = function(timesToRepeat) {
   var string = this;

   for (var i = 1; i < timesToRepeat; i++) {
      string += this;/* w  w  w .j  a  v  a  2  s.co m*/
   }

   return string;
};

Related

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