Function leftPad

Adds the padWith (default ' ') to the string the amount of times specified by the space argument

  • Parameters

    • str: string

      String to add padding to

    • space: number

      Whitespace to add

    • padWith: string = ' '

      Character to use to pad the string

    Returns string

    const padded = leftPad("Hello", 3, ".");

    console.log(padded); // '...Hello'