vanillajs-helpers

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS

View the Project on GitHub Tokimon/vanillajs-helpers

vanillajs-helpers > “leadingZero”

External module: “leadingZero”

Index

Functions


Functions

leadingZero

leadingZero(num: numberstring, 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 numberstring - Number to add leading zeroes to
len number 2 linimum length of the returned string

Returns: string