Javascript String rpad(padString, length)

Description

Javascript String rpad(padString, length)


//pads right/*from   ww w.j a  v a  2s  .  com*/
String.prototype.rpad = function(padString, length) {
 var str = this;
    while (str.length < length)
        str = str + padString;
    return str;
}

Javascript String rpad(padString, length)

'use strict';//from  w  w  w  .  ja va  2s . co  m

/* eslint-disable no-extend-native */

String.prototype.rpad = function(padString, length) {
  let str = this;
  while (str.length < length) {
    str = str + padString;
  }
  return str;
};

Javascript String rpad(padString, length)

//pads right/*from  ww  w .  j  a v a 2  s. c  o m*/
String.prototype.rpad = function(padString, length) {
 var str = this;
 while(str.length < length)
  str = str + padString;
 return str;
};



PreviousNext

Related