Node.js examples for String:Padding
Left/Right justified String
String.prototype.leftJustified = function(n, fill) { fill = fill || " "; var padding = ""; for (var i = n - this.length; i > 0; i--) { padding += fill;//from ww w .jav a 2 s . c om } return this + padding; }; String.prototype.rightJustified = function(n, fill) { fill = fill || " "; var padding = ""; for (var i = n - this.length; i > 0; i--) { padding += fill; } return padding + this; };