Necesito formatear precios por unidad. es decir 2 336 €/m² , $2.336/ac .
Intl.NumberFormat funciona con currency O estilo de unit . No puedo usar ambos.
¿Cómo será un formato de moneda por unidad?
Tienes TRES problemas
const sups = ["²", "³"]; const currencyPerUnit = (amount, unit, sup, noDec, locale = "en-US", currency = "USD", ) => { const numberWithCurrency = (amount).toLocaleString(locale, { style: 'currency', currency: currency, minimumFractionDigits: noDec ? 0 : 2, }); const units = (amount).toLocaleString('fr-FR', { style: 'unit', unit: unit, unitDisplay: 'short' }).split(/\s+/).pop(); return `${numberWithCurrency}/${units}${sup ? sups[sup-2] : ""}`; }; console.log(currencyPerUnit(1234, "meter", 2, true, "fr-FR", "EUR")); // Euro per m² in French console.log(currencyPerUnit(1234.14, "acre", 0, false)); // USD per acre console.log(currencyPerUnit(1234.14, "acre", 2, true, "fr-FR", "EUR")); // Eure per square acre in French