Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #2388

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Develop #2388

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/makeRobotAccountant.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
'use strict';

/**
*
* @return {function}
*/

function makeRobotAccountant() {
// write code here
let callCount = 0;

return function(a) {
return function(b) {
callCount++;

if (callCount <= 3 || callCount % 2 !== 0) {
return a + b;
}

return 'Bzzz... Error!';
};
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CODE STYLE] - You don't need to name functions if you return them right away. Consider using anonymous functions instead to make the code cleaner. For example, return function (b) { ... };

}

module.exports = makeRobotAccountant;
Loading