Skip to content

js_array_reverse#167

Open
Alex-redman wants to merge 2 commits intomate-academy:mainfrom
Alex-redman:develop
Open

js_array_reverse#167
Alex-redman wants to merge 2 commits intomate-academy:mainfrom
Alex-redman:develop

Conversation

@Alex-redman
Copy link

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.

Review Summary

Your Jest tests cover many essentials (function existence, return type, empty inputs, single/multi-element cases), but a few critical requirements are missing from the task specification. Specifically, the tests must include the exact example cases: ['Hell0'] -> ['0lleH'] and ['I','am','a','student!'] -> ['!','tn','e','dutsamaI'] (add these to src/arrayReverse.test.js near your other example checks). Also add an explicit length-1 string case and a test to ensure the input array is not mutated (immutability). For example, copy the input before calling arrayReverse and assert input remains equal to the copy. These changes ensure coverage of digits/special symbols and document the expected behavior precisely. Finally, confirm src/arrayReverse.js exists and exports arrayReverse so the new tests run. Great work so far—add these required tests and we’ll be good to approve.


✨ 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


it(`should return an empty string
if original array consists of an empty string`, () => {
it('should return an array with reversed strings', () => {

Choose a reason for hiding this comment

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

Add the exact multi-element example required by the task description to ensure redistribution across multiple very-short strings and special symbols is covered. For example:

expect(arrayReverse(['I', 'am', 'a', 'student!'])).toEqual(['!', 'tn', 'e', 'dutsamaI']);

This verifies length-1 behaviour and special-symbol handling as specified in the description.


it('should return an array with a single reversed string', () => {
expect(arrayReverse(['Mate'])).toEqual(['etaM']);
});

Choose a reason for hiding this comment

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

Add the single-string example from the description that includes a digit. For example:

expect(arrayReverse(['Hell0'])).toEqual(['0lleH']);

This directly matches the specification and ensures numbers inside strings are handled correctly.

expect(arrayReverse(['', ''])).toEqual(['', '']);
});

it('should return an array with a single reversed string', () => {

Choose a reason for hiding this comment

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

Add an explicit test for very-short (length-1) strings if you want a dedicated check (the multi-element example above covers it, but an explicit test makes intent clear). Example:

expect(arrayReverse(['a'])).toEqual(['a']);
expect(arrayReverse(['x','y'])).toEqual(['y','x']); // or other short combinations

This ensures the function handles minimal-length strings as required.

});

// write more tests here
it('should preserve original array length', () => {

Choose a reason for hiding this comment

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

Add a test to assert the original input array is not mutated (immutability). For example:

const input = ['Mate', 'Academy'];
const copy = [...input];
arrayReverse(input);
expect(input).toEqual(copy);

This ensures tests don't rely on in-place mutation and documents expected behaviour.

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

Decision: REQUEST_CHANGES

Your test file src/arrayReverse.test.js is strong and covers the required examples and edge cases well. However, there is a critical blocker: the tests require('./arrayReverse') (see src/arrayReverse.test.js top import), but no src/arrayReverse.js implementation was provided in the submission. Without this file exporting the function (e.g., module.exports = arrayReverse), Jest will fail to load the module and all tests will error out rather than validate behavior.

Required fixes:

  • Ensure src/arrayReverse.js exists and exports the function as module.exports = arrayReverse so that require('./arrayReverse') in the test resolves correctly.

Nice-to-have (not required to pass):

  • Add an immutability test near the single-string cases to confirm the input array isn’t mutated.

Once the implementation file is added with the correct export, the test suite should run as intended. Great job on the comprehensive test coverage and clear example assertions!


✨ 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


describe(`Function 'arrayReverse':`, () => {
const arrayReverse = require('./arrayReverse');
const arrayReverse = require('./arrayReverse');

Choose a reason for hiding this comment

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

This file requires the implementation with require('./arrayReverse'). Make sure src/arrayReverse.js exists at that path and exports the function (e.g. module.exports = arrayReverse). If the file is missing or exported under a different name/path the tests will fail to load the module.

});

it("should handle ['Hell0'] -> ['0lleH']", () => {
expect(arrayReverse(['Hell0'])).toEqual(['0lleH']);

Choose a reason for hiding this comment

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

Good — the single-item example with digits is present and asserts the exact expected output from the description (['Hell0'] -> ['0lleH']). This satisfies the requirement to test strings containing numbers along with letters.

expect(arrayReverse(['', ''])).toEqual(['', '']);
});

it('should return an array with a single reversed string', () => {

Choose a reason for hiding this comment

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

Suggestion: add an immutability test to ensure the input array is not mutated by arrayReverse. For example, copy the input before calling the function and assert the original equals the copy afterwards. Place this test near the single-string tests so behavior is clearly documented (not required by the description but recommended).

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

good job

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