Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 664 Bytes

pad.md

File metadata and controls

35 lines (23 loc) · 664 Bytes

strings.pad

pad(string, [length=0], [substr=' '])

Pads the both ends of a string w/ repeated spaces|substrings

Arguments

  1. string (string): input string
  2. [length=0] (number): length of the padded portion
  3. [substr=' '] (string): substring to apply

Returns

(string): the input padded w/ spaces|substrings

Example

// if no `substr` is provided, it pads the string w/ spaces
const result = strings.pad('xyzxyz', 9);
console.log(result);
> ' xyzxyz  '