JavaScript · Intermediate · Ticket 8Ticket #26 · from Kwame Mensah, Designer
  1. Example
  2. Warm-up 1
  3. Warm-up 2
  4. Ticket
Brief
NEW TICKET#26 · Client page

Payment streak with one missed month forgiven

Kwame Mensah · Designer
Opened today

“We're adding a "Reliable payer" badge to the client page: "Paid on time 11 months running". Count the months in a row the client paid on time, going back from last month. Life happens, so one missed month is forgiven: it doesn't add to the count, but it doesn't end the streak either. A second missed month ends it. The months come from the payments table, so they're in no particular order, and a month can be there twice when two invoices were paid. Hannah wrote prevMonth, which turns "2027-01" into "2026-12". Can you write paymentStreak?”

YOUR PLAN
  1. 1Watch an example2 min
  2. 2Warm-up 11 min
  3. 3Warm-up 21 min
  4. 4Fix the ticket21 min
BY THE END YOU CAN
  • Use a Set to remove duplicates and look things up fast
  • Walk back through months with a helper
  • Allow one exception with a flag
About 25 minutes
Four short steps. Nothing is timed, and you can leave any time.