From 4b51ccc728eba26f13f94e32122a6c0322dbd889 Mon Sep 17 00:00:00 2001 From: YarynaPuhach Date: Fri, 23 Feb 2024 09:18:26 +0100 Subject: [PATCH] Created a function `makeRobotAccountant` --- src/makeRobotAccountant.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/makeRobotAccountant.js b/src/makeRobotAccountant.js index 38b9758a..d0b28e48 100644 --- a/src/makeRobotAccountant.js +++ b/src/makeRobotAccountant.js @@ -6,7 +6,21 @@ */ function makeRobotAccountant() { - // write code here + let count = 0; + + const getSum = function(a) { + count++; + + return function(b) { + if (count > 3 && count % 2 === 0) { + return 'Bzzz... Error!'; + } + + return a + b; + }; + }; + + return getSum; } module.exports = makeRobotAccountant;