Created
January 28, 2020 17:46
-
-
Save hperantunes/0fd92de6e02ef80550de28f2d37d0543 to your computer and use it in GitHub Desktop.
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
function decimalPlaces(value) { | |
const match = ("" + value).match(/(?:[,.](\d+))?(?:[eE]([+-]?\d+))?$/); | |
if (!match) { | |
return 0; | |
} | |
return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment