pad
Modified on Mon, 31 Jul 2023
Description
Pad string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length
Syntax
pad(text, length, chars)
Parameters
Input Parameter | Type | Description |
---|---|---|
text | string | The string to pad. |
length | number | The padding length. |
chars | string | The string used as padding. |
Return value
Type |
---|
string |
Sample
Example | Result | Description |
---|---|---|
pad('Sam', 8, ' ') | ' Sam ' | Pad input text with given charcters |
pad('Sam', 8, '-+') | '-+Sam-+-' | Pad input text with given charcters |
To view all the String functions, click here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article