Skip to content

solution#1060

Open
Radymyr wants to merge 4 commits intomate-academy:mainfrom
Radymyr:develop
Open

solution#1060
Radymyr wants to merge 4 commits intomate-academy:mainfrom
Radymyr:develop

Conversation

@Radymyr
Copy link

@Radymyr Radymyr commented Jan 27, 2026

func failed the last test

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 writing a comprehensive set of tests for the splitInteger function! You've covered several important cases. However, changes are needed because the test suite is currently failing due to an incorrect expectation in one of your tests.

In src/splitInteger.test.js, the test for splitInteger(3, 4) expects [0, 0, 0, 0]. This is incorrect because the sum of the parts must equal the original value (3). Your implementation's actual output, [0, 1, 1, 1], is correct. Please update the test to expect the correct result.

Additionally, for the splitInteger(20, 1) test, a more robust assertion would be expect(result).toEqual([20]). This verifies the entire array's structure and content, not just the value of the first element.


✨ 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

when splitting into 1 part`, () => {
const result = splitInteger(20, 1);

expect(result[0]).toBe(20);

Choose a reason for hiding this comment

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

This assertion is not strict enough because it only checks the value of the first element. It doesn't verify that the array has exactly one element as required. A better approach is to check the entire array, for example: expect(result).toEqual([20]);.

test(`should add zeros if value < numberOfParts`, () => {
const result = splitInteger(3, 4);

expect(result).toEqual([0, 0, 0, 0]);

Choose a reason for hiding this comment

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

The expected result here is incorrect. The sum of the elements in the returned array should equal the original value. In this case, splitInteger(3, 4) should return an array whose elements sum to 3. The provided implementation correctly returns [0, 1, 1, 1], which meets all the requirements. This test should be updated to expect the correct output.

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

Excellent work addressing the previous feedback! The corrections you've made have significantly improved the test suite. This requires a few final changes because the submission is missing tests for some specific examples required by the task description. To complete the requirements, please add tests for the following cases:

  • splitInteger(8, 1)
  • splitInteger(6, 2)
  • splitInteger(17, 4)
  • splitInteger(32, 6)

You are very close to finishing. Keep up the great work!


✨ 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

const result = splitInteger(3, 4);

expect(result).toEqual([0, 1, 1, 1]);
});

Choose a reason for hiding this comment

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

Great work on the existing tests! To fully meet the requirements, please add tests for all the specific examples provided in the task description, such as splitInteger(17, 4) and splitInteger(32, 6). These examples are required to ensure the function is fully verified against the specification.

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

Excellent work on this pull request! You've successfully addressed all the feedback from the previous review by adding the required test cases. The test suite is now comprehensive and correctly validates the function's behavior against all specified requirements.

I am approving your solution. I have one small suggestion to improve the organization of your tests in src/splitInteger.test.js for better readability. The test description 'should split integer into equal parts' is a bit confusing because the assertions on lines 15 and 16 test cases with unequal parts. Consider moving them to the 'should sort parts ascending if they are not equal' test block to keep related tests together.

This is just a suggestion for future reference, not a required change. Great job!


✨ 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 12 to 17
test(`should return a part equals to a value
when splitting into 1 part`, () => {

expect(splitInteger(20, 1)).toEqual([20]);
expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]);
expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]);
});

Choose a reason for hiding this comment

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

This test description is a bit confusing because it only describes the first assertion. The assertions on lines 15 and 16 test cases where the value is split into multiple, unequal parts. Consider moving them to the 'should sort parts ascending if they are not equal' test block to keep related tests together.

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