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 #2319

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

Develop #2319

Show file tree
Hide file tree
Changes from 2 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
81 changes: 67 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"license": "GPL-3.0",
"devDependencies": {
"@mate-academy/eslint-config": "*",
"@mate-academy/scripts": "^0.3.6",
"@mate-academy/scripts": "^1.2.8",
"eslint": "^5.16.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-node": "^8.0.1",
Expand Down
20 changes: 20 additions & 0 deletions src/makeRobotAccountant.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@

function makeRobotAccountant() {
// write code here
// random comment cuz i forgot to switch branch and need to make changes :P
let counter = 0;

function getSum(a) {
function bullshitNesting(b) {
if (counter > 2 && counter % 2 === 1) {
counter++;

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


return `Bzzz... Error!`;

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

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.

} else {

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 

counter++;

return a + b;

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

Choose a reason for hiding this comment

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

same as above

}
}

return bullshitNesting;
}

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.


return getSum;
}

module.exports = makeRobotAccountant;