Last active
October 6, 2016 01:54
-
-
Save joadr/4e8c782436720bb5db5af87b0821f0c4 to your computer and use it in GitHub Desktop.
Gist to truncate a chilean format.
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
// Original price | |
var price = '$2.968.945' | |
// remove $ and . | |
price = price.replace(/\$/g,'').replace(/\./g,'') | |
// convert to Int | |
price = parseInt(price) | |
// Divide by 1000 and truncate to remove extra digits | |
price = Math.trunc(price/1000) | |
// Format the final price | |
price = price*1000-10 | |
// Price output --> 2967990 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment