diff --git a/src/tax.js b/src/tax.js new file mode 100644 index 0000000..82ea4dc --- /dev/null +++ b/src/tax.js @@ -0,0 +1,3 @@ +export function salesTax(amountCents, ratePercent) { + return Math.round((amountCents * ratePercent) / 100); +} diff --git a/src/tax.test.js b/src/tax.test.js new file mode 100644 index 0000000..4d70fb0 --- /dev/null +++ b/src/tax.test.js @@ -0,0 +1,7 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { salesTax } from "./tax.js"; + +test("salesTax rounds to the nearest cent", () => { + assert.equal(salesTax(1999, 8.25), 165); +});