Skip to content

Instantly share code, notes, and snippets.

@dav1app
Last active April 17, 2021 23:53
Show Gist options
  • Save dav1app/be8b183b0442cb2eda225e2be37a390a to your computer and use it in GitHub Desktop.
Save dav1app/be8b183b0442cb2eda225e2be37a390a to your computer and use it in GitHub Desktop.
A nice way to parse money in JS
export default correctInput(input){
let result
result = input.replace(',','')
result = parseInt(result)
result = result.toString()
result = result.padStart(3,'0')
result = result.substr(0,result.length-2)+","+ result.substr(result.length-2,2)
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment