-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
add task solution #2601
base: master
Are you sure you want to change the base?
add task solution #2601
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.
Awesome job! Your solution is compact, simple and easy to read, keep it up!
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.
Your implementation of the makeCalculator
function is almost there! 🎉 However, there's a critical issue with the operate
method that needs to be addressed. The method should verify that the operation
is a function before invoking it. This can be done by adding a check like if (typeof operation === 'function')
. This change will ensure that your code handles unexpected inputs gracefully and meets the task requirements. Once you make this adjustment, your solution will be ready to go! Keep up the great work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
src/makeCalculator.js
Outdated
operate(operation, value) { | ||
operation(value); |
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 operate
method should check if operation
is a function before invoking it. You can do this by adding a check like if (typeof operation === 'function')
before calling operation(value);
. This ensures that the method is used correctly and prevents runtime errors if a non-function is passed.
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 implementing the makeCalculator
function! 🎉 Your code meets the task requirements and constraints effectively. The function correctly returns an object with the necessary methods, and the operate
method now properly checks if the operation
is a function before invoking it.
However, there's a minor issue: the operate
method doesn't return the result of the operation, which might be expected in some use cases. Consider returning the result for improved usability.
Your use of method chaining and shorthand syntax is commendable and aligns well with the task guidelines.
Remember, addressing these minor issues will enhance your code's functionality and usability. Keep up the great work, and continue learning from each task! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
src/makeCalculator.js
Outdated
|
||
operate(operation, value) { | ||
if (typeof operation === 'function') { | ||
operation(value); |
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 operate
method invokes the operation
function but does not return its result. If the operation is expected to return a value, consider returning it here for better usability.
No description provided.