padEnd

Modified on Mon, 31 Jul 2023

Description

Pad string on the right side if it's shorter than length. Padding characters are truncated if they exceed length

Syntax

padEnd(text, length, chars)

Parameters

Input ParameterTypeDescription
textstringThe string to pad.
lengthnumberThe padding length.
charsstringThe string used as padding.

Return value

Type
string

Sample

ExampleResultDescription
pad('Sam', 6, ' ')'Sam 'Pad three spaces at the end
pad('Sam', 6, '-+')'Sam-+-'Add characters to the end of the input text

To view all the String functions, click here.

See Also