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

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

Method Source Code

String.prototype.repeatify = String.prototype.repeatify || function(num){
  "use strict";/*  www  .j  a  va2s  . co m*/
  let newString = "";
  while(num >0){
    newString +=this;
    num--;
  }
  return newString;
};

const b ="Brown";
console.log(b.repeatify(3));

Related

  1. 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));
    
  2. 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));
    
  3. repeatify(times)
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
       var str = '';
       for (var i = 0; i < times; i++) {
          str += this;
       return str;
    };
    
  4. repeatify(timesToRepeat)
    String.prototype.repeatify = function(timesToRepeat) {
       var string = this;
       for (var i = 1; i < timesToRepeat; i++) {
          string += this;
       return string;
    };
    
  5. 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))
    ...
    
  6. 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));
    
  7. 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));
    
  8. 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));  
    
  9. repeatrepeat(count)
    String.prototype.repeat = function repeat(count) {
      'use strict';
      if (this === undefined || this === null) {
        throw new TypeError(this + ' is not an object');
      if (count < 0 || count === Infinity) {
        throw new RangeError(count + ' is less than zero or equal to infinity');
      return new Array((parseInt(count, 10) || 0) + 1).join(this);
    ...