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 #61

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

solution #61

wants to merge 2 commits into from

Conversation

KachVl
Copy link

@KachVl KachVl commented Jan 14, 2025

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.


It looks like there's a critical issue with the implementation of your reduce function in src/reduce.js. The test is designed to ensure that the callback is called with four arguments: the accumulator, current value, current index, and the array itself. Please review your implementation to ensure it meets this requirement. Once this is addressed, your tests should pass successfully. Keep up the good work, and don't hesitate to reach out if you need further assistance! 😊

✨ 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 +36 to +39
it('callback should be called with four arguments', () => {
testArr.reduce2(cb, 0);

expect(cb.mock.calls[0].length).toBe(4);

Choose a reason for hiding this comment

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

The test checks if the callback is called with four arguments. Ensure that your reduce implementation in src/reduce.js correctly passes the accumulator, current value, current index, and the array itself to the callback function.

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.


It looks like there's a critical issue with the test for the reduce function. The test assumes that the callback function is called with four arguments, which might not align with the actual implementation. This discrepancy could lead to incorrect test results and potentially mask issues in the reduce function itself. Please verify and adjust the implementation or the test to ensure they are consistent. Once this is resolved, your code will be in great shape! Keep up the good work and don't hesitate to reach out if you need any help. 😊

✨ 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 36 to 40
it('callback should be called with four arguments', () => {
testArr.reduce2(cb, 0);

expect(cb.mock.calls[0].length).toBe(4);
});

Choose a reason for hiding this comment

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

The test assumes that the callback function is called with four arguments. Ensure that the reduce function implementation actually provides four arguments to the callback. Typically, the reduce callback receives the accumulator, current value, current index, and the array itself, but this should be verified against the actual implementation.

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

Great effort on implementing the test for the reduce function! 🎉 However, there are a few critical issues that need attention:

  • Callback Arguments: The test case incorrectly assumes that the callback function is always called with four arguments. According to the standard Array.prototype.reduce method, the callback should be called with accumulator, currentValue, currentIndex, and the array itself. Ensure your implementation aligns with this standard behavior.

  • Test Alignment: The task requires writing tests for a custom implementation of the reduce method. It's crucial that your tests accurately reflect the expected behavior of the standard reduce function.

While the decision is to APPROVE this Pull Request to help you move forward with your learning, it's important to address these issues in future iterations to avoid similar problems. Take this opportunity to review the comments and improve your code. Keep up the good work and continue learning from these experiences! 🚀

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

Comment on lines +36 to +40
it('callback should be called with four arguments', () => {
testArr.reduce2(cb, 0);

expect(cb.mock.calls[0].length).toBe(4);
expect(cb.mock.calls[0]).toEqual([0, 1, 0, testArr]);

Choose a reason for hiding this comment

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

The test case assumes that the callback function is called with four arguments. Verify the implementation of the reduce function to ensure it matches this expectation. If the implementation does not call the callback with four arguments, this test will fail or produce misleading results.

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

Great job on implementing the custom Array.prototype.reduce method and writing tests for it! 🎉 However, there's a critical issue with the test case that checks if the callback function is called with four arguments. The standard reduce function typically calls the callback with three arguments: the accumulator, the current value, and the current index. The fourth argument, the array itself, is optional. Please verify your implementation to ensure it aligns with this behavior, or adjust the test case accordingly.

This decision to approve is made to help you move forward with your learning journey. It's important to address this issue in future iterations to avoid similar problems. Keep up the good work, and use this opportunity to refine your skills and improve your code! 💪

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

Comment on lines +36 to +40
it('callback should be called with four arguments', () => {
testArr.reduce2(cb, 0);

expect(cb.mock.calls[0].length).toBe(4);
expect(cb.mock.calls[0]).toEqual([0, 1, 0, testArr]);

Choose a reason for hiding this comment

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

The test case assumes that the callback function is called with four arguments. However, the standard reduce function calls the callback with only three arguments: the accumulator, the current value, and the current index. The fourth argument, the array itself, is optional. Please verify the implementation of your reduce function to ensure it aligns with this behavior, or adjust the test case accordingly.

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