Command Palette

Search for a command to run...

Hectal
Phase 22: Architecture and Patterns
React · Exercise 4 of 5 PreviousNext
Advanced

An order summary for any locale

The order summary hard-codes US formats. Make it follow the locale chosen in #locale (en-US uses USD, de-DE uses EUR, ja-JP uses JPY).

#total shows the amount 1234.5 formatted with Intl.NumberFormat as currency. #date shows the order date with Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).

#items shows 1 item or N items in English, choosing the form with new Intl.PluralRules("en-US"). #more adds one item.

What Check tests

  1. With one item it says 1 item
  2. With two items it says 2 items
  3. en-US shows $1,234.50 and Jan 15, 2024
  4. de-DE shows euros and a German date
  5. ja-JP shows yen with no decimals

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.