See also: padR, padL

Inserts padding on both sides, returning a character string from a character expression padded to a specified length.

Syntax

JSV_padC(expS, expN [, expP])

Prototype

expS.JSV_padC(expN [, expP])

Returns

The padC functions returns the specified expression padded on both sides of the string.

Parameters

The padC functions use the following arguments.

Argument Description
expS The character to be padded.
expN Specifies the total number of characters in the expression after it is padded.
expP The value used for padding. If expP is omitted, spaces are used for padding. If expP is included, the value of expP is repeated as necessary to pad the expression expS to a length of expN characters.

Remarks

n/a

Dependencies

JSV_isEmpty, JSV_replicate

Example

The following lines of code

var testString = "Busy";
document.write( JSV_padC(testString, 12, "@") );
testString = "1234";
document.write( JSV_padC(testString, 12, "-") );

produce