format amount in javascript
const formatToCurrency = amount => {
return "$" + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,");
};
formatToCurrency(12.34546); //"$12.35"
formatToCurrency(42345255.356); //"$42,345,255.36
Also in JavaScript:
- smtpjs cdn
- adding bootstrap to angular global styles
- node.js mysql wildcard
- what is code.jquery integrity crossorigin
- javascript round down
- change span value javascript
- js insert in array
- how to make a ping command on a discord bot discord.js
- react can't import file 3 folders up
- jquery when iframe is loaded
- multiline comment in react
- process.stdin.on('data'
- from json timestamp to date python
- javascript remove last character of string
- jquery get current row value
- perform a function on each element of array javascript
- rails call multiple variable format json
- chai compare arrays
- how to create react native project at specific version
- Cannot find module '@angular/cdk/a11y'
- access text inside a button from js
- angular delete from array by name
- how to check if value is undefines if condition jquery
- jquery find div with data attribute value