LPad Function in JavaScript

 function LPad(ContentToSize,PadLength,PadChar)  {     var PaddedString=ContentToSize.toString();     for(i=ContentToSize.length+1;I<=PadLength;i++)     {         PaddedString=PadChar+PaddedString;     }     return PaddedString;  }Arguments:ContentToSize - Content to be PaddedPadLength -Length of the string after paddingPadChar - Character to be Padded if the String is length is lesser thenPadLengtheg.LPad(a,4,"0") will return 000a
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: