diff --git a/source/_posts/2021/split-bill.md b/source/_posts/2021/split-bill.md index be4a3f8..a2b7288 100644 --- a/source/_posts/2021/split-bill.md +++ b/source/_posts/2021/split-bill.md @@ -61,13 +61,13 @@ const data = new Map(); for (const { payer, amount, involves } of history) { const record = data.fetch(payer); record.balance += amount; - const dept = Math.ceil(amount / involves.length); - // actual payer should not owe extra dept coming from rounded up numbers - const payerDept = amount - dept * (involves.length - 1); - for (const deptor of involves.map((i) => data.fetch(i))) { + const debt = Math.ceil(amount / involves.length); + // actual payer should not owe extra debt coming from rounded up numbers + const payerDebt = amount - debt * (involves.length - 1); + for (const debtor of involves.map((i) => data.fetch(i))) { const cost = Math.round(amount / involves.length); - deptor.balance -= cost; - deptor.consumption += cost; + debtor.balance -= cost; + debtor.consumption += cost; } }