“Formatwährung JavaScript” Code-Antworten

Formatmenge 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
Delightful Dotterel

JavaScript -Formatwährung

function formatToCurrency(amount){
    return (amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); 
}
formatToCurrency(12.34546); //"12.35"
formatToCurrency(42345255.356); //"42,345,255.36"
Pro___coder$

JavaScript -Formatnummer als Währung

const formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
  minimumFractionDigits: 2
})

formatter.format(1000) // "$1,000.00"
formatter.format(10) // "$10.00"
formatter.format(123233000) // "$123,233,000.00"
Super Lazy Coder

So formatieren Sie Geld als Währungszeichenfolge

(12345.67).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');  // 12,345.67
Real Reindeer

JS -Format Urcurecy

// Create our number formatter.
var formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
});

formatter.format(2500); /* $2,500.00 */
Lonely Curly Boi

Formatwährung JavaScript

(12345.67).toFixed(2).replace(/\d(?=(\d{3})+\,)/g, '$&,');  // 12,345.67
Arrogant Alligator

Ähnliche Antworten wie “Formatwährung JavaScript”

Fragen ähnlich wie “Formatwährung JavaScript”

Weitere verwandte Antworten zu “Formatwährung JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen