Format a number as currency

Javascript

Intl handles the symbol, the separators and the decimal places for the locale, so you never hand-roll them.

const gbp = new Intl.NumberFormat('en-GB', {
  style: 'currency',
  currency: 'GBP',
});

gbp.format(1234.5);   // '£1,234.50'

More in JavaScript

Random picks