From 64263687ac670a2508bc6c4cf732bfd21c063894 Mon Sep 17 00:00:00 2001 From: Maksym Kostetskyi Date: Fri, 13 Oct 2023 11:23:36 +0300 Subject: [PATCH] solution --- src/makeRobotAccountant.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/makeRobotAccountant.js b/src/makeRobotAccountant.js index 38b9758a..57305303 100644 --- a/src/makeRobotAccountant.js +++ b/src/makeRobotAccountant.js @@ -6,7 +6,21 @@ */ function makeRobotAccountant() { - // write code here + let counter = 0; + + return function(a) { + return function(b) { + counter++; + + if (counter >= 4 && counter % 2 === 0) { + return `Bzzz... Error!`; + } + + const sum = a + b; + + return sum; + }; + }; } module.exports = makeRobotAccountant;