From 2adfc7b123f2f7ef648c4dde08db1007c8c08cb8 Mon Sep 17 00:00:00 2001 From: Daniel Bajer Date: Thu, 23 May 2024 14:16:17 +0200 Subject: [PATCH] Solution makeRobotAccountant --- src/makeRobotAccountant.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/makeRobotAccountant.js b/src/makeRobotAccountant.js index 38b9758a..c0238abd 100644 --- a/src/makeRobotAccountant.js +++ b/src/makeRobotAccountant.js @@ -6,7 +6,21 @@ */ function makeRobotAccountant() { - // write code here + let count = 0; + + function getSum(a) { + return function(b) { + count++; + + if (count > 3 && count % 2 === 0) { + return 'Bzzz... Error!'; + } else { + return a + b; + } + }; + } + + return getSum; } module.exports = makeRobotAccountant;