From b18e6dad9f8cdbb422914ae266494a6e1c52b529 Mon Sep 17 00:00:00 2001 From: Dmytro Nikulin Date: Fri, 27 Feb 2026 15:34:08 +0200 Subject: [PATCH 1/2] Add solution --- src/arrayReverse.test.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index cf8ac47..ddfb4c0 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -8,13 +8,31 @@ describe(`Function 'arrayReverse':`, () => { }); it(`should return an array`, () => { - + expect(arrayReverse(['Hello'])).toBeInstanceOf(Array); }); it(`should return an empty string if original array consists of an empty string`, () => { - expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); + expect(arrayReverse([''])).toEqual(['']); }); // write more tests here + it(`should return an array with a reversed string + if original array has only one sentence`, () => { + expect(arrayReverse(['Hell0'])).toEqual(['0lleH']); + }); + + it(`should return an array with reverses + and keep original array string lengths + if original array has two or more sentences`, () => { + expect(arrayReverse(['Mate', 'Academy'])).toEqual(['ymed', 'acAetaM']); + }); + + it(`should return an array with reverses + and keep original array string lengths + if original array has two or more sentences + (including numbers and punctuation)`, () => { + expect(arrayReverse(['I', 'am', 'a', 'student!'])) + .toEqual(['!', 'tn', 'e', 'dutsamaI']); + }); }); From 7f14f4e9b3f46a2cd5cb39443d2c094d171c15be Mon Sep 17 00:00:00 2001 From: Dmytro Nikulin Date: Fri, 27 Feb 2026 15:37:37 +0200 Subject: [PATCH 2/2] Added edge case for empty array --- src/arrayReverse.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arrayReverse.test.js b/src/arrayReverse.test.js index ddfb4c0..1179ab8 100644 --- a/src/arrayReverse.test.js +++ b/src/arrayReverse.test.js @@ -35,4 +35,8 @@ describe(`Function 'arrayReverse':`, () => { expect(arrayReverse(['I', 'am', 'a', 'student!'])) .toEqual(['!', 'tn', 'e', 'dutsamaI']); }); + + it('should return an empty array if original array is empty', () => { + expect(arrayReverse([])).toEqual([]); + }); });