/**
* Format a number as a localized currency string.
* @param {number} amount - The value to format
* @param {string} currency - ISO 4217 currency code
*/
function formatCurrency(amount, currency = 'USD') {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency,
minimumFractionDigits: 2,
}).format(amount);
}
// Usage
formatCurrency(4299); // → "$4,299.00"