-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
base: master
Are you sure you want to change the base?
Solution #2322
Conversation
src/makeRobotAccountant.js
Outdated
const error = 'Bzzz... Error!'; | ||
|
||
return (a) => { | ||
count++; |
There was a problem hiding this comment.
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.
src/makeRobotAccountant.js
Outdated
return error; | ||
} | ||
|
||
const sum = a + b; |
There was a problem hiding this comment.
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
src/makeRobotAccountant.js
Outdated
@@ -6,7 +6,22 @@ | |||
*/ | |||
|
|||
function makeRobotAccountant() { | |||
// write code here | |||
let count = 0; | |||
const error = 'Bzzz... Error!'; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
There was a problem hiding this 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.
src/makeRobotAccountant.js
Outdated
return (b) => { | ||
count++; | ||
|
||
if (count > 3 & count % 2 === 0) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
No description provided.