Skip to content

Solution#85

Open
ViktoriiaPylypko wants to merge 4 commits intomate-academy:masterfrom
ViktoriiaPylypko:develop
Open

Solution#85
ViktoriiaPylypko wants to merge 4 commits intomate-academy:masterfrom
ViktoriiaPylypko:develop

Conversation

@ViktoriiaPylypko
Copy link

solvesTask

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

Thanks for your hard work! Your test suite for reduce2 covers many important cases and is well-structured, but it is missing several critical required edge cases (such as handling empty arrays without an initial value, callback argument checks, sparse arrays, array-like objects, and error handling for invalid callbacks). Please add tests for these scenarios to fully meet the task requirements. You're almost there—keep going! 🚀


✨ 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

Viktoriia Pylypko added 2 commits July 20, 2025 15:36
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

Thank you for your hard work so far! Before your PR can be approved, you need to add tests for several critical edge cases: callback argument checks, sparse arrays, array-like objects, and error handling for invalid callbacks. These are required by the task checklist and MDN documentation. Please update your test suite to include these scenarios, and you'll be all set! 🚀


✨ 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

expect(arr.reduce2((acc, val) => acc + val)).toBe(undefined);
});
});
// Add tests here

Choose a reason for hiding this comment

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

You are missing required edge case tests as per the task checklist: callback argument checks, sparse arrays, array-like objects, and error handling for invalid callbacks. Please add tests for these scenarios.

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 work on your test suite for the custom reduce implementation! 🎉 Your tests are comprehensive, covering a wide range of scenarios including argument checks, error handling, mutation checks, and various data types, all in line with the MDN specification and the task checklist. Your code is clear, well-structured, and follows all style and constraint guidelines.

However, there is one important issue to address: the test for skipping holes in sparse arrays is currently skipped using it.skip. Since the checklist requires this edge case to be actively tested, you should enable this test by removing .skip. This will ensure your suite fully verifies the correct behavior for sparse arrays.

Additionally, if you are working on the reduce2 implementation itself, make sure to add a check at the start of your function to ensure the callback is a function, returning undefined if not. This will help you pass all related tests.

Overall, you’re on the right track! Please review the comments and make the suggested improvements, especially enabling the sparse array test. Keep up the great work and continue learning—addressing these details will help you become an even better developer! 🚀


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

Footnotes

  1. Rate AI review example

Comment on lines +70 to +89
it.skip('should skip holes in sparse arrays', () => {
const arr = [1, 3];

arr.splice(1, 0); // тепер arr = [1, <empty>, 3]

const visited = [];

const result = arr.reduce2((acc, val, i) => {
visited.push([i, val]);

return acc + (val || 0);
}, 0);

expect(result).toBe(4);

expect(visited).toEqual([
[0, 1],
[2, 3],
]);
});

Choose a reason for hiding this comment

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

The test for skipping holes in sparse arrays is currently skipped using it.skip. If the task checklist requires this edge case to be actively tested, please enable this test by removing .skip.

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