cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

zero-fill.js (352B)


      1export default function zeroFill(number, targetLength, forceSign) {
      2    var absNumber = '' + Math.abs(number),
      3        zerosToFill = targetLength - absNumber.length,
      4        sign = number >= 0;
      5    return (
      6        (sign ? (forceSign ? '+' : '') : '-') +
      7        Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
      8        absNumber
      9    );
     10}