Last active
July 17, 2018 19:00
-
-
Save williammustaffa/c295f9ba19262ac22fc047069effe658 to your computer and use it in GitHub Desktop.
custom toFixed to prevent rounding values
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
| Number.prototype.customToFixed = function (digits) { | |
| return parseFloat(String(this).replace(new RegExp(`(\\d+\\.\\d{${digits}}).*`), '$1')); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment