StaffCoder
TypeScript
Vanilla TypeScriptTypeScript 7.0
6 modules · 24 challengesSign up
Module 6 · Arrays & Data Transformation

Group Bookings By Day

easy—No data yet

Problem statement

A schedule view whose per-day groups miss any day with no bookings and drop bookings that don't sit on a hand-listed day. A grouping function must take an in-memory bookings array and a chronological list of day keys and produce one entry per requested day — with each day's bookings sorted by start time and counted — using Vanilla TypeScript.

Demo

The page, styles, mock data, panel markup, and DOM rendering are already scaffolded and wired. Only the groupBookingsByDay function in src/js/bookings.ts is missing — implement it so every test passes. Do not edit any other file.

What to implement

  • Produce one entry per requested day, in the same chronological order the days were supplied.
  • Put each booking under the day whose key matches the day part of the booking's start time.
  • Order each day's bookings from the earliest start time to the latest.
  • Include every day in the requested range even when it has no bookings, keeping its list empty and its count at zero.
  • Give each day a count that matches the number of bookings shown for that day.
  • Drop any booking whose day is not part of the requested range.
  • Leave the bookings you were given and the requested days you were given unchanged.
  • Everything shown must come from the bookings and days you were given — nothing should be hardcoded.

More in Arrays & Data Transformation

See the module
Leaderboard SortingSort leaderboard entries by score descending with a documented tiebreak (earlier finish time, then name) without mutating the input. Support an ascending toggle and return a position for each entry, sharing a position number across genuine ties. The order is stable across repeated calls.—No data yeteasyOrder TotalsCompute an order summary from an order-lines array using map, filter, and reduce: item count, subtotal, discount total, tax, and grand total, excluding cancelled lines from every figure. An empty order returns zeros — never NaN or null — and a line with zero quantity contributes nothing. The input array is never mutated.—No data yeteasyInventory Summary PanelTransform a stock array into a summary (total value, low-stock count, out-of-stock list, top categories by value) and render each part into the panel. Values render formatted, every derived figure comes from the transform rather than the DOM, and re-running with new data replaces the rendered summary rather than appending.—No data yeteasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.