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

Solution #2322

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

Solution #2322

wants to merge 4 commits into from

Conversation

MarcinLigmann
Copy link

No description provided.

const error = 'Bzzz... Error!';

return (a) => {
count++;
Copy link

Choose a reason for hiding this comment

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

I wonder whether we should increment count in this place. Right now, the count will be incremented even if we don't invoke the last returned function.

I would put it in the last function, but it is not specified in the task description so I leave the decision to you. I just wanted to make sure that you are aware of this closure behavior.

return error;
}

const sum = a + b;
Copy link

Choose a reason for hiding this comment

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

Since we are using this value only once, there is no need to create a variable for it. Simply return the calculation

@@ -6,7 +6,22 @@
*/

function makeRobotAccountant() {
// write code here
let count = 0;
const error = 'Bzzz... Error!';
Copy link

Choose a reason for hiding this comment

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

Same as with the sum (see below)

Copy link

@marcinzrodlowski marcinzrodlowski left a comment

Choose a reason for hiding this comment

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

Looks good :)

Copy link

@mbruhler mbruhler left a comment

Choose a reason for hiding this comment

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

Please add changes from comments.

return (b) => {
count++;

if (count > 3 & count % 2 === 0) {

Choose a reason for hiding this comment

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

This is not a logical operator here (&), you should use the proper one.

Choose a reason for hiding this comment

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

you use here bitwise operator

Copy link

@mvjl000 mvjl000 left a comment

Choose a reason for hiding this comment

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

Good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants