Created
January 25, 2017 08:37
-
-
Save Panigale/5bb7483313a96ff6676fc585341064b7 to your computer and use it in GitHub Desktop.
This file contains 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 characters
function currency(value){ | |
value += ""; | |
var arr = value.split("."); | |
var re = /(\d{1,3})(?=(\d{3})+$)/g; | |
return arr[0].replace(re, "$1,") + (arr.length == 2 ? "." + arr[1] : ""); | |
} | |
export {currency}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment