Created
September 13, 2018 17:55
-
-
Save indefinitelee/8ae2e6568a6ed7b893dd4b24433734c5 to your computer and use it in GitHub Desktop.
SereneExemplaryConference created by indefinitelee1 - https://repl.it/@indefinitelee1/SereneExemplaryConference
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
const dollarFormat = (amount, defaultValue) => { | |
console.log(amount) | |
if (!amount) | |
return defaultValue; | |
const result = `${parseFloat(amount).toFixed(2)}`.replace(/\B(?=(\d{3})+(?!\d))/g, ','); | |
console.log(result) | |
if (isNaN(result)) | |
return defaultValue | |
else | |
return '$' + result; | |
} | |
const cpm = 44444.44 | |
const otherDollarFormat = (amount, defaultValue) => amount ? `$${parseFloat(amount).toFixed(2)}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : defaultValue; | |
dollarFormat(cpm, '$0' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment