padEnd
  • 23 May 2023
  • Dark
    Light
  • PDF

padEnd

  • Dark
    Light
  • PDF

Article summary

padEnd Task Purpose

The padEnd task is used to pad the end of a string with another string (repeated, if needed) so that the resulting string reaches a specified length. The padding is applied from the right end of the given string.

Potential Use Case

Suppose you have a dataset of a known length and you would like to have that dataset repeated at the end of the current dataset. You could use the padEnd task to specify the numeric length and variables needed to "pad" or be added to the end of the original dataset.

Properties

Input and output parameters are shown below.

Incoming Type Description
str String Required. The string to pad.
targetLength Number Required. The desired length of the resulting string once the string has been padded. If the value is less than the str length, then the task returns the original str.
padString String Required. The string to pad the original string with. If this value is too long to be within the targetLength, it is truncated.


Outgoing Type Description
paddedString String A string of a specified length that has been padded at the end with a given string.

Example

In this IAP example:

  • The str variable has been set with the words "Hello World" and the current length of the string is 11 spaces or characters, but the new targetLength is set to 14.

  • The padString variable to apply until the string reaches 14 characters in length is an exclamation mark ("!").

    padEnd-01

  • The expected end result will be "Hello World!!!", and the end of the word string for "Hello World" has been padded with three "!!!" exclamation marks in order to fulfill the specified targetLength.

    padEnd-02


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.