Javascript Number toPercent(n)

Description

Javascript Number toPercent(n)


Number.prototype.toPercent = function(n) {
 n = n || 0;//  w  ww . j  a  v a  2  s  .  c om
 return (Math.round(this * Math.pow(10, n + 2)) / Math.pow(10, n)).toFixed(n) + '%';
}



PreviousNext

Related