-
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
Solution #2599
base: master
Are you sure you want to change the base?
Solution #2599
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.
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.
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.
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.
-
Operate Method: The
operate
method should apply the callback to both the currentresult
and the providednumber
. This ensures that the operation is performed correctly. Please update the method to usethis.result = callback(this.result, number);
. -
Method Updates: The
add
,subtract
,multiply
, anddivide
methods should update theresult
property of the calculator object instead of just returning the result. This will ensure that theresult
is correctly updated and allow for method chaining. For example, changereturn calc.result + num;
tocalc.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.
add(num) { | ||
return calc.result + num; |
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 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.
subtract(num) { | ||
return calc.result - num; |
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 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.
multiply(num) { | ||
return calc.result * num; |
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 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.
divide(num) { | ||
return calc.result / num; |
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 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.
operate(callback, number) { | ||
this.result = callback(number); |
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 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.
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.
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:
-
Operate Method: The
operate
method should apply the callback to both the currentresult
and the providednumber
. Update your code tothis.result = callback(this.result, number);
to ensure the operation is performed correctly. -
Arithmetic Methods: The
add
,subtract
,multiply
, anddivide
methods should update theresult
property of the calculator object. For example, usecalc.result += num;
foradd
, and similarly for the other methods. Additionally, each method should returnthis
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; |
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 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; |
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 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; |
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 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; |
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 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); |
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 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.
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.
Good job 👍
No description provided.