Skip to content

Add solution#3063

Open
Skoulskiy wants to merge 2 commits into
mate-academy:masterfrom
Skoulskiy:develop
Open

Add solution#3063
Skoulskiy wants to merge 2 commits into
mate-academy:masterfrom
Skoulskiy:develop

Conversation

@Skoulskiy

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because there is a required checklist violation in src/makeCalculator.js, even though the functionality itself is correct. Your makeCalculator implementation meets the behavioral requirements: it returns an object with add, subtract, multiply, divide, reset, operate, and a result getter, the result starts at 0, operate and reset are chainable, and operate can use arbitrary callbacks (including but not limited to the calculator’s own methods). However, per the checklist (see [CHECKLIST ITEM #3]), methods defined on an object must use the object method shorthand, not arrow functions assigned to properties. On the lines where you currently have something like add: (a, b) => a + b (and similarly for subtract, multiply, and divide), you should change these to method shorthand, e.g. add(a, b) { return a + b; }. This is a style requirement that is explicitly mandated by the checklist, so it counts as a blocking issue for this task and needs to be corrected before the solution can be considered complete. Once you update those four methods to use the shorthand syntax, the rest of your solution looks solid and should pass both the functional and style requirements. Keep the overall structure as it is—your chaining logic and callback flexibility are well done.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/makeCalculator.js Outdated
Comment on lines +13 to +16
add: (a, b) => a + b,
subtract: (a, b) => a - b,
multiply: (a, b) => a * b,
divide: (a, b) => a / b,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #3: if you creating a method in the object, you don't need to use function keyword, use shortcut instead. Here add, subtract, multiply, and divide are defined as properties with arrow functions instead of using the object method shorthand, which the checklist expects for methods.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Your solution is approved because it satisfies all functional and style requirements for makeCalculator. The function correctly returns a calculator object with add, subtract, multiply, divide, operate, reset, and a result getter backed by an internal currentResult initialized to 0. The operate(callback, number) method properly applies the callback to the current result, updates it, and returns this to support chaining, and reset also resets the value to 0 while remaining chainable. All object methods use the required shorthand method syntax, and there is no misuse of reassignment patterns flagged in [CHECKLIST ITEM #2]. You also respected the requirement that operate not restrict callbacks to only calculator methods, while still keeping the implementation clear and straightforward. Overall, the code is clean, readable, and aligned with the example usage and checklist expectations—nice 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.

2 participants