Skip to content

Conversation

@dmytro-halieba
Copy link

No description provided.

Copy link

@DemonWayne DemonWayne left a comment

Choose a reason for hiding this comment

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

Looks okay, specified some minor problems below

Comment on lines 10 to 30
add(number) {
return this.result += number;
},

subtract(number) {
return this.result -= number;
},

multiply(number) {
return this.result *= number;
},

divide(number) {
return this.result /= number;
},

reset() {
this.result = 0;

return this;
},

Choose a reason for hiding this comment

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

Those returns are unnecessary 'cause we use those functions as callbacks and don't really expect them to return anything, so I think we can remove those returns.

Choose a reason for hiding this comment

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

Oh, don't mind that I also selected reset here; ignore this comment about reset.

},

divide(number) {
return this.result /= number;
Copy link

@DemonWayne DemonWayne Dec 30, 2025

Choose a reason for hiding this comment

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

I think that raw divide could be harmful and break all calculations if number is zero. We would probably get infinity, and that's maybe not an expected behavior for this calculator. Could you check if the number is zero and maybe throw an error or reset the result?

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 90be0ae

},

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

Choose a reason for hiding this comment

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

And here we don't need this assigning, we already assign value in the called callbacks

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 90be0ae

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.

Review Summary

I am approving your submission. You've done an excellent job implementing the makeCalculator function. All requirements have been met, including the creation of all necessary methods and the correct implementation of method chaining for operate and reset. Your code is clean, well-structured, and adheres to all the style guidelines. Great work!


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

Footnotes

  1. Rate AI review example

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