From 729388b308a583dbd378da96de885a71717fdcef Mon Sep 17 00:00:00 2001 From: Dominik Dudek Date: Thu, 17 Oct 2024 23:06:15 +0200 Subject: [PATCH] Task solution --- src/makeRobotAccountant.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/makeRobotAccountant.js b/src/makeRobotAccountant.js index 38b9758a..f1f740d8 100644 --- a/src/makeRobotAccountant.js +++ b/src/makeRobotAccountant.js @@ -6,7 +6,19 @@ */ function makeRobotAccountant() { - // write code here + let numberOfCalls = 0; + + return (numberOne = 0) => { + return (numberTwo = 0) => { + numberOfCalls++; + + const numbersSum = numberOne + numberTwo; + + return numberOfCalls > 3 && numberOfCalls % 2 === 0 + ? `Bzzz... Error!` + : numbersSum; + }; + }; } module.exports = makeRobotAccountant;