From 63928f71652019c21a2e57002147101e82df14c5 Mon Sep 17 00:00:00 2001 From: itty-todder <50145463+itty-todder@users.noreply.github.com> Date: Sun, 6 Feb 2022 18:16:12 +0200 Subject: [PATCH 1/2] Update README.md npm install will install all needed dependencies(including jest) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1e741a3..c842a65 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ That's actually a good question. I guess that discovery does not happen with a s # How to run? -from console, install jest +from console, install with npm: ``` -npm install --save-dev jest +npm install ``` then you can just run the tests @@ -45,4 +45,4 @@ npm test if you want to benchmark use ``` npm run bench -``` \ No newline at end of file +``` From db556e2b5a1d148be1bc11ba887b9ff928cf74d6 Mon Sep 17 00:00:00 2001 From: "itty.todder" Date: Sun, 6 Feb 2022 18:29:06 +0200 Subject: [PATCH 2/2] Octal solution --- The73Calculator.js | 8 +++++++- The73Calculator.test.js | 8 +++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/The73Calculator.js b/The73Calculator.js index 6f2938c..7172672 100644 --- a/The73Calculator.js +++ b/The73Calculator.js @@ -68,6 +68,12 @@ module.exports = class The73Calculator { return n; } - static noop(n) {} + static octal(n) { + let numberAsOctal = (n + 4).toString(8) + numberAsOctal = parseInt(numberAsOctal) % 10 + + return numberAsOctal; + } + static noop(n) {} }; \ No newline at end of file diff --git a/The73Calculator.test.js b/The73Calculator.test.js index 377bb21..ec2c767 100644 --- a/The73Calculator.test.js +++ b/The73Calculator.test.js @@ -49,14 +49,12 @@ describe("The73Calculator", () => { test(The73Calculator.usingPolynom.name, () => { expectBehavior(The73Calculator.usingPolynom); }); - - - + test(The73Calculator.octal.name, () => { + expectBehavior(The73Calculator.octal); + }); function expectBehavior(f) { expect(f(3)).toBe(7); expect(f(7)).toBe(3); } - - }); \ No newline at end of file