Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS
vanillajs-helpers > “leadingZero”
► leadingZero(num: number⎮string, len?: number): string
Defined in leadingZero.ts:14
Makes sure a given number is a certain length and fills excess space with zeroes (0)
leadingZero(1); // -> '01'
leadingZero(123); // -> '123'
leadingZero(123, 5); // -> '00123'
Parameters:
| Param | Type | Default value | Description |
|---|---|---|---|
| num | number⎮string |
- | Number to add leading zeroes to |
| len | number |
2 | linimum length of the returned string |
Returns: string