From 49188cbe174f6f0559037bb2f6e51300dac90a85 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 23 May 2019 14:37:46 -0700 Subject: [PATCH] Handle the fully-deductible case --- tax.js | 3 +-- tax.test.js | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tax.js b/tax.js index 7f32f74..d9bd34c 100644 --- a/tax.js +++ b/tax.js @@ -53,8 +53,6 @@ function merge_tax_tables(t1, t2) { } function invert(table) { - if (table.length == 0) return x => x; - // Here we solve // net = m * gross + b // for gross: @@ -90,5 +88,6 @@ function invert(table) { return (net - b) / m; } } + return net; }; } diff --git a/tax.test.js b/tax.test.js index 14c48c0..125cc20 100644 --- a/tax.test.js +++ b/tax.test.js @@ -57,5 +57,6 @@ test("invert", () => { assert.strictEqual(invert([ ])(10), 10); assert.strictEqual(invert([[ 0, Infinity, .1]])( 9), 10); assert.strictEqual(invert([[10, Infinity, .1]])(19), 20); + assert.strictEqual(invert([[10, Infinity, .1]])( 9), 9); assert.strictEqual(invert([[0, 100, .1], [100, Infinity, .2]])(170), 200); }); -- 2.44.1