Created
March 25, 2018 04:10
-
-
Save uinz/e6b224687f9f8fc4e34e4c5b92c0a236 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 formate(num) { | |
| return num.toFixed(8).replace(/(.+\.\d\d+?)(0+?)$/, '$1') | |
| } | |
| formate(0.10000) // 0.10 | |
| formate(0.111111000) // 0.111111 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment