Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
Intl NumberFormat moneda por unidad

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tienes TRES problemas

  1. Formato de número internacional para moneda
  2. Formato de número internacional para unidades
  3. Uso de unidades que no son compatibles: notación exponencial para Intl.NumberFormat

 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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!