Nodejs String Padding Right rpad(padString, length)

Here you can find the source of rpad(padString, length)

Method Source Code

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

Related

  1. rpad(count, pad)
    String.prototype.rpad = function(count, pad) {
        pad = pad || '0';
        str = this + '';
        return str.length >= count ? str : str + new Array(count - str.length + 1).join(pad);
    };
    
  2. rpad(padString, length)
    'use strict';
    String.prototype.rpad = function(padString, length) {
      var str = this;
      while (str.length < length) {
        str = str + padString;
      return str;
    };
    
  3. rpad(padString, length)
    String.prototype.rpad = function(padString, length) {
      var str = this;
      while(str.length < length)
        str = str + padString;
      return str;
    
  4. rpad(padString, length)
    String.prototype.rpad = function(padString, length) {
      var str = this;
        while (str.length < length){
            str = str + padString;
        return str;
    
  5. rpad(padString, length)
    String.prototype.rpad = function(padString, length) {
      var str = this;
        while (str.length < length)
            str = str + padString;
        return str;
    };
    
  6. rpad(pad_str, length)
    String.prototype.rpad = function(pad_str, length) {
      var str = this;
      while (str.length < length) str = str + pad_str;
      return str;