JS Utils Kit - v0.5.1
    Preparing search index...

    Function padRight

    • Pads a string on the right with a specified character until it reaches the desired length.

      Parameters

      • str: string

        The string to pad.

      • length: number

        The target length of the padded string.

      • char: string = ' '

        The character to use for padding (defaults to a space).

      Returns string

      The padded string, or the original string if its length is already greater than or equal to the target length.

      console.log(padRight("hello", 8)); // "hello   "
      console.log(padRight("hi", 5, "*")); // "hi***"
      console.log(padRight("hello", 3)); // "hello"
      console.log(padRight("", 3, "0")); // "000"