-
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
Develop #2319
base: master
Are you sure you want to change the base?
Develop #2319
Conversation
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.
the comments are just my suggestions, the code looks good and works.
I approve :)
src/makeRobotAccountant.js
Outdated
if (counter > 2 && counter % 2 === 1) { | ||
counter++; | ||
|
||
return `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.
would wrap it in a variable, e.g. error, then return 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.
Actually, since we are not doing operations on this variable, it does not change or appear in different places, it's not a part of a list of options (like in stateful clones) we don't need to wrap it in a variable.
src/makeRobotAccountant.js
Outdated
} else { | ||
counter++; | ||
|
||
return 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.
here I would also wrap in a variable sum and return the sum
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 above
src/makeRobotAccountant.js
Outdated
function getSum(a) { | ||
function bullshitNesting(b) { | ||
if (counter > 2 && counter % 2 === 1) { | ||
counter++; | ||
|
||
return `Bzzz... Error!`; | ||
} else { | ||
counter++; | ||
|
||
return a + b; | ||
} | ||
} | ||
|
||
return bullshitNesting; | ||
} |
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 can just use arrow functions () => {}
instead off naming your functions bullshitNesting
. Please remember to avoid such Easter eggs.
src/makeRobotAccountant.js
Outdated
if (counter > 2 && counter % 2 === 1) { | ||
counter++; | ||
|
||
return `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.
Actually, since we are not doing operations on this variable, it does not change or appear in different places, it's not a part of a list of options (like in stateful clones) we don't need to wrap it in a variable.
src/makeRobotAccountant.js
Outdated
} else { | ||
counter++; | ||
|
||
return 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.
same as above
src/makeRobotAccountant.js
Outdated
function getSum(a) { | ||
function bullshitNesting(b) { | ||
if (counter > 2 && counter % 2 === 1) { | ||
counter++; |
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.
move counter++
outside of if statements
src/makeRobotAccountant.js
Outdated
counter++; | ||
|
||
return `Bzzz... Error!`; | ||
} else { |
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.
if you are using if
with return
there is no need for else
keyword
if {
//code
return
}
return // some other code
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!
No description provided.