Javascript Number pad(size, c)

Description

Javascript Number pad(size, c)


Number.prototype.pad = function (size, c) {
    let s = String(this);
    while (s.length < (size || 2)) {
        s = (c || ' ') + s;
    }/*w  ww  .  j a v a  2 s  .  c  o m*/

    return s;
}



PreviousNext

Related