Javascript Number withCommas()

Description

Javascript Number withCommas()

Number.prototype.withCommas = function() {
  var x = 3;//from w w  w  . j a  va2 s. c om
  var y = parseFloat(this).toString().reverse();
  while (x < y.length) {
    y = y.substring(0, x) + "," + y.substring(x); 1
    x += 4;
  }
  return y.reverse();
};



PreviousNext

Related