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

add task solution #2601

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

Conversation

AnOvramenko
Copy link

No description provided.

Copy link

@daniil-trusov daniil-trusov left a 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!

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.

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.

Comment on lines 10 to 11
operate(operation, value) {
operation(value);

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.

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.

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


operate(operation, value) {
if (typeof operation === 'function') {
operation(value);

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.

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