-
-
Save ecaepsey/a32d19483ae486d6427cafa6bd3b011e to your computer and use it in GitHub Desktop.
Format SUm
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
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