padzeros

Returns a string padded with leading zeros

Usage no npm install needed!

<script type="module">
  import padzeros from 'https://cdn.skypack.dev/padzeros';
</script>

README

Pad Zeros

The following function returns a string containing the formatted representation of a number padded with leading zeros.

Usage

var result;
result = padzeros(42,4); // returns "0042"
result = padzeros(42,2); // returns "42"
result = padzeros(5,4);  // returns "0005"

Installation

$ npm install padzeros