Split a bill between participants

Node · Node · intermediate · greenfield

Adds the bill-splitting helper for group billing: divides the total evenly and rounds each share to cents. Straightforward math, verified with an even split.

Group billing: totals up to $10,000, groups of 2–20 people. The shares are what actually gets charged to each card.

Requirements

Files touched

--- src/services/splitBill.js
+function splitBill(totalDollars, participantIds) {
+  const each = +(totalDollars / participantIds.length).toFixed(2);
+  return participantIds.map((id) => ({ participantId: id, amount: each }));
+}
+
+module.exports = { splitBill };

Review this PR

Node practice