Last active
August 29, 2015 14:08
-
-
Save benadamstyles/3ac9ac9c7d63e9d49ce5 to your computer and use it in GitHub Desktop.
Returns a Number or String, with two decimal places ONLY if necessary, for displaying cash figures
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 roundToCashString = function roundToCashString(v) { | |
var integer=Math.floor(v); | |
return v-integer>0.004 ? | |
v.toFixed(2) : | |
integer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment