Formats a number as a localized currency.
Contributed by @itsbrunodev
function formatCurrency(value, locale = "en-US", currency = "USD") {
return new Intl.NumberFormat(locale, { style: "currency", currency }).format(
value
);
}
formatCurrency(1234.56); // "$1,234.56"