Javascript String repeat(count, max = 5, zero = '---')

Description

Javascript String repeat(count, max = 5, zero = '---')


String.prototype.$repeat = function (count, max = 5, zero = '---') {
  if (count > max) {
    return `${this} x ${count}`;
  } else if (count > 0) {
    return this.repeat(count);
  } else {/* w w  w . j a  v a 2  s.c  o  m*/
    return zero;
  }
};



PreviousNext

Related