Skip to content

Split Integer Test Solution#1020

Closed
arberzylyftari wants to merge 1 commit into
mate-academy:mainfrom
arberzylyftari:develop
Closed

Split Integer Test Solution#1020
arberzylyftari wants to merge 1 commit into
mate-academy:mainfrom
arberzylyftari:develop

Conversation

@arberzylyftari
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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

Decision: Approve — the implementation and tests work and meet the core functionality requirements.

Your splitInteger implementation behaves correctly, and the current tests verify key scenarios (equal split, single-part, ordering for a non-trivial case, and a value < parts case). There are no critical blockers: functionality is intact and tests are valid. For further strengthening, consider adding explicit property assertions (length equals numberOfParts, sum equals value, and max - min <= 1) and include the missing example splitInteger(32, 6) to mirror the description. For broader coverage of zeros, splitInteger(2, 5) would be a good addition. Minor style note: in .eslintrc.js, replacing the numeric severity 0 with 'off' for no-proto improves readability. Nicely done overall — clear code and thoughtful tests; the suggested additions will make the suite even more robust.


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

Footnotes

  1. Rate AI review example

Comment thread .eslintrc.js
'no-proto': 0,
strict: 0,
'max-len': 0,
'no-proto': 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The rule entry uses a numeric severity (0). ESLint accepts numeric severities, but consider using the equivalent string ('off') for clarity and readability, e.g.:

'no-proto': 'off'

This is a low-severity readability suggestion — functionality is unchanged if you keep 0.

Comment thread src/splitInteger.test.js
test(`should split a number into equal parts
if a value is divisible by a numberOfParts`, () => {

expect(splitInteger(6,2)).toEqual([3,3]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good assertion: this verifies the equal-split case when the value is divisible by numberOfParts. Consider adding the other example from the description (splitInteger(32, 6)) to ensure the tests include all provided examples. This would make tests mirror the description examples exactly.

Comment thread src/splitInteger.test.js
test(`should return a part equals to a value
when splitting into 1 part`, () => {

expect(splitInteger(6,1)).toEqual([6]);
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 correctly tests splitting into a single part. As a minor improvement, you could also add the splitInteger(8, 1) example shown in the description to increase coverage of provided examples.

Comment thread src/splitInteger.test.js

test('should sort parts ascending if they are not equal', () => {

expect(splitInteger(17,4)).toEqual([4,4,4,5]);
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 assertion checks ascending order and the max-min difference property for a non-trivial case — good. You could complement this with a property-style test that asserts length, sum, sorted order, and max-min <= 1 for several inputs to catch regression bugs more reliably.

Comment thread src/splitInteger.test.js

test('should add zeros if value < numberOfParts', () => {

expect(splitInteger(1,2)).toEqual([0,1]);
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 correctly tests the value < numberOfParts scenario for a simple case. Consider adding a case where multiple zeros occur (for example, splitInteger(2, 5) should yield [0,0,0,1,1]) to verify correct distribution when many parts are larger than the value.

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