format currency 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(12345.67).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); // 12,345.67function formatToCurrency(amount){
return (amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
formatToCurrency(12.34546); //"12.35"
formatToCurrency(42345255.356); //"42,345,255.36"SteveSteven Jasper CSteven Jasper Calcaro
Also in JavaScript:
- javascript date
- How to find the max id in an array of objects in JavaScript
- javascript assignment operator if undefined
- javascript project ideas
- mac os chrome opne debug new tab
- javascript replace big list
- datatables clear table
- access selected option in jquery
- node js http request get parameters
- access json python
- promise nodejs
- send message to user facebook game
- position of the mouse cursor javascript
- get first element of array javascript
- js change button text
- javascript conditional
- disable input jquery
- first element of array js
- compare two arrays and make sure there are no duplicates js
- angular usehash not working
- anonymous function javascript
- how to refrence image in dart angular
- getting the value of pi in javascript
- react dropdown menu stack overflow