Round a number by digit - Node.js Math

Node.js examples for Math:Round

Description

Round a number by digit

Demo Code


Number.prototype.ToRound = function (digits) {
    if (digits < 0 || digits > 10)
        return this;
    var pow10 = Math.pow(10, digits);
    return Math.round(this * pow10) / pow10;
};

Related Tutorials