Repeats the string num times - Node.js String

Node.js examples for String:Repeat

Description

Repeats the string num times

Demo Code


/**//from   w ww  .ja  va2s. co m
 * Repeats the string num times.
 * @param num
 * @returns
 */
String.prototype.repeat = function(num) {
  return new Array(num+1).join(this);
};

Related Tutorials