Skip to content

Commit

Permalink
Directly returned functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilbykow committed Sep 5, 2024
1 parent 131cca0 commit dc93de1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/makeRobotAccountant.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
function makeRobotAccountant() {
let countCalls = 0;

function sum(a) {
function add(b) {
return (a) => {
return (b) => {
countCalls++;

return countCalls % 2 === 0 && countCalls > 3 ? 'Bzzz... Error!' : a + b;
}

return add;
}

return sum;
};
};
}

module.exports = makeRobotAccountant;

0 comments on commit dc93de1

Please sign in to comment.