padEnd

The padEnd task pads 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

Use this task when you have a dataset of a known length and want to repeat a value at the end of the current dataset. You can use padEnd to specify the target length and the string to append.

Properties

IncomingTypeDescription
strStringRequired. The string to pad.
targetLengthNumberRequired. The desired length of the resulting string after padding. If the value is less than the length of str, the task returns the original str unchanged.
padStringStringRequired. The string to use for padding. If it is too long to fit within targetLength, it is truncated.
OutgoingTypeDescription
paddedStringStringThe padded string of the specified length.

Example

  • The str variable is set to "Hello World" (length: 11 characters). The targetLength is set to 14.
  • The padString is "!".
padEnd task — input

The result is "Hello World!!!" — three exclamation marks are appended to reach the specified targetLength of 14.

padEnd task — output