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

Solution #2599

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

Solution #2599

wants to merge 2 commits into from

Conversation

anhrytsan
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

Something went wrong while processing the review.
[CODE: 2]

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on the makeCalculator function! 🚀 While your implementation is mostly on point, there are a few critical issues that need to be addressed to meet the core requirements of the task.

  1. Operate Method: The operate method should apply the callback to both the current result and the provided number. This ensures that the operation is performed correctly. Please update the method to use this.result = callback(this.result, number);.

  2. Method Updates: The add, subtract, multiply, and divide methods should update the result property of the calculator object instead of just returning the result. This will ensure that the result is correctly updated and allow for method chaining. For example, change return calc.result + num; to calc.result += num; return this;.

Once these changes are made, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you have any questions. 😊

✨ 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.

Comment on lines +9 to +10
add(num) {
return calc.result + num;

Choose a reason for hiding this comment

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

The add method should update calc.result with the new value instead of just returning it. Change return calc.result + num; to calc.result += num; return this; to ensure the result is updated and the method is chainable.

Comment on lines +12 to +13
subtract(num) {
return calc.result - num;

Choose a reason for hiding this comment

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

The subtract method should update calc.result with the new value instead of just returning it. Change return calc.result - num; to calc.result -= num; return this; to ensure the result is updated and the method is chainable.

Comment on lines +15 to +16
multiply(num) {
return calc.result * num;

Choose a reason for hiding this comment

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

The multiply method should update calc.result with the new value instead of just returning it. Change return calc.result * num; to calc.result *= num; return this; to ensure the result is updated and the method is chainable.

Comment on lines +18 to +19
divide(num) {
return calc.result / num;

Choose a reason for hiding this comment

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

The divide method should update calc.result with the new value instead of just returning it. Change return calc.result / num; to calc.result /= num; return this; to ensure the result is updated and the method is chainable.

Comment on lines +26 to +27
operate(callback, number) {
this.result = callback(number);

Choose a reason for hiding this comment

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

The operate method should apply the callback to the current result and the provided number. Change this.result = callback(number); to this.result = callback(this.result, number); to ensure the operation is performed correctly.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your submission! While your implementation of the makeCalculator function shows promise, there are a few critical issues that need to be addressed to fully meet the task requirements. Here’s a summary of the key points to focus on:

  1. Operate Method: The operate method should apply the callback to both the current result and the provided number. Update your code to this.result = callback(this.result, number); to ensure the operation is performed correctly.

  2. Arithmetic Methods: The add, subtract, multiply, and divide methods should update the result property of the calculator object. For example, use calc.result += num; for add, and similarly for the other methods. Additionally, each method should return this to allow method chaining.

These changes are crucial for the correct functionality of your calculator and to support method chaining as required. Although the decision is to APPROVE this pull request to help you move forward with your learning, it is important to address these issues in future iterations to avoid similar problems. Keep up the good work, and continue to learn and improve from this experience! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

result: 0,

add(num) {
return calc.result + num;

Choose a reason for hiding this comment

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

The add method should update the result property of the calculator object. Change this line to calc.result += num; and return this to allow method chaining.

},

subtract(num) {
return calc.result - num;

Choose a reason for hiding this comment

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

The subtract method should update the result property of the calculator object. Change this line to calc.result -= num; and return this to allow method chaining.

},

multiply(num) {
return calc.result * num;

Choose a reason for hiding this comment

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

The multiply method should update the result property of the calculator object. Change this line to calc.result *= num; and return this to allow method chaining.

},

divide(num) {
return calc.result / num;

Choose a reason for hiding this comment

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

The divide method should update the result property of the calculator object. Change this line to calc.result /= num; and return this to allow method chaining.

},

operate(callback, number) {
this.result = callback(number);

Choose a reason for hiding this comment

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

The operate method should apply the callback to both the current result and the provided number. Update this line to this.result = callback(this.result, number); to ensure the operation is performed correctly.

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Good job 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants