Skip to content

Instantly share code, notes, and snippets.

@renventura
Created April 26, 2024 11:23
Show Gist options
  • Save renventura/6dfdea10257add53b56ba786e4b0142f to your computer and use it in GitHub Desktop.
Save renventura/6dfdea10257add53b56ba786e4b0142f to your computer and use it in GitHub Desktop.
Javascript code to format a number to USD currency
const formatUSD = (value) => {
return new Intl.NumberFormat(
'en-US',
{
style: 'currency',
currency: 'USD'
}
).format(value);
}
// $50.00
formatUSD(50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment