Nodejs Utililty Methods Number to Percentage Format

List of utility methods to do Number to Percentage Format

Description

The list of methods to do Number to Percentage Format are organized into topic(s).

Method

toPercent(n)
Number.prototype.toPercent = function(n) {
  n = n || 0;
  return (Math.round(this * Math.pow(10, n + 2)) / Math.pow(10, n)).toFixed(n) + '%';
toPercent(ofTotalAmount)
Number.prototype.toPercent = function (ofTotalAmount) {
    "use strict";
    var n, t;
    var sign, suffix, i;
    n = this;
    try {
        t = (typeof ofTotalAmount === 'undefined' || isNaN(ofTotalAmount)) ? 100 : ofTotalAmount;
        if (t === 0) throw "division exception averted";
        if (t <= n) throw "is too low";
...
toPercent(places)
Number.prototype.toPercent = function(places) {
  return (this * 100).toFixed(places) + '%';
};
toPercentage(radix)
Number.prototype.toPercentage = function (radix) {
    var num = this * 100;
    return num.roundToFixed(radix);
};