pad.js 293 Bytes Edit 1 2 3 4 5 6 7 8 9 10 'use strict' export default function (source, length = 2) { let pre = "" const negative = source < 0 const string = String(Math.abs(source)) if (string.length < length) { pre = (new Array(length - string.length + 1)).join('0') } return (negative ? "-" : "") + pre + string }