Skip to content

Instantly share code, notes, and snippets.

@Panigale
Created January 25, 2017 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Panigale/5bb7483313a96ff6676fc585341064b7 to your computer and use it in GitHub Desktop.
Save Panigale/5bb7483313a96ff6676fc585341064b7 to your computer and use it in GitHub Desktop.
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