JavaScript · Beginner · Ticket 2Ticket #2 · from Kwame Mensah, Designer
  1. Example
  2. Warm-up 1
  3. Warm-up 2
  4. Ticket
Brief
NEW TICKET#2 · Invoice page

Show cents as dollars

Kwame Mensah · Designer
Opened today

“The new invoice page prints amounts straight from the database, so a client sees “Total: 123456” instead of $1,234.56. Ledgerwick stores money as whole cents, so we need one function that turns cents into what people expect to read. Hannah already wrote addCommas for the thousands. Refunds are stored as negative amounts and should read like -$5.00. Can you finish formatMoney?”

YOUR PLAN
  1. 1Watch an example2 min
  2. 2Warm-up 11 min
  3. 3Warm-up 21 min
  4. 4Fix the ticket11 min
BY THE END YOU CAN
  • Split a number with Math.floor and %
  • Pad a number to two digits with padStart
  • Build text from parts with +
About 15 minutes
Four short steps. Nothing is timed, and you can leave any time.