Skip to content

Instantly share code, notes, and snippets.

@ecaepsey
Created March 6, 2019 05:04
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 ecaepsey/a32d19483ae486d6427cafa6bd3b011e to your computer and use it in GitHub Desktop.
Save ecaepsey/a32d19483ae486d6427cafa6bd3b011e to your computer and use it in GitHub Desktop.
Format SUm
var input = 222323.34343;
function formatSum(sum) {
if(Number.isInteger(sum)) {
return sum
}
var beforeDot = /[^.]*/.exec(sum)[0]
var afterDot = /(?<=\.).*/.exec(sum)[0]
return beforeDot + ',' + afterDot
}
console.log(formatSum(input))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment