-
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 #2383
base: master
Are you sure you want to change the base?
Solution #2383
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.
Great job on the Pull Request! 🌟 While there are some minor code style suggestions, such as simplifying conditional logic and using anonymous functions, these don't significantly impact the functionality or security of your code. Keep these tips in mind for cleaner and more efficient code in your future work! Happy coding! 😊👍
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
src/makeRobotAccountant.js
Outdated
function makeRobotAccountant() { | ||
// write code here | ||
let count = 0; | ||
|
||
return function(a) { | ||
return function(b) { | ||
count++; | ||
|
||
if (count <= 3 || count % 2 !== 0) { | ||
const sum = a + b; | ||
|
||
return sum; | ||
} else { | ||
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.
[CODE STYLE] - You don't need to name functions if you return them right away. Consider using anonymous functions instead.
src/makeRobotAccountant.js
Outdated
if (count <= 3 || count % 2 !== 0) { | ||
const sum = a + b; | ||
|
||
return sum; | ||
} else { | ||
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.
[CODE STYLE] - DRY. When you do similar logic, try to combine conditions. Here, you can simplify the conditional logic by checking for count > 3 and count % 2 === 0 as a single case to return 'Bzzz... Error!' and return the sum in all other cases.
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.
Well done 🥇
No description provided.