Created
December 20, 2013 08:47
-
-
Save manufaktor/8052102 to your computer and use it in GitHub Desktop.
Revisions
-
manufaktor created this gist
Dec 20, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ Number.prototype.toCurrency = function() { var value; if (isNaN(this) || !isFinite(this)) { return '-'; } value = Math.abs(this).toFixed(2); value = value.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); return (this < 0 ? '-$' : '$') + value; }; Number.prototype.toPercent = function() { if (isNaN(this) || !isFinite(this)) { return '-'; } return Math.abs(this * 100).toFixed(2) + '%'; };