From 473e15f4fbfeb561a1850d03b5b2467c1946c982 Mon Sep 17 00:00:00 2001 From: Ihor Haidai Date: Mon, 26 Jan 2026 18:08:32 -0500 Subject: [PATCH 1/2] Add task solution --- src/splitInteger.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index a610317d..f6aeaaff 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -4,18 +4,24 @@ const splitInteger = require('./splitInteger'); test(`should split a number into equal parts if a value is divisible by a numberOfParts`, () => { - + expect(splitInteger(12, 3)).toEqual([4, 4, 4]); + expect(splitInteger(6, 2)).toEqual([3, 3]); }); test(`should return a part equals to a value when splitting into 1 part`, () => { - + expect(splitInteger(8, 1)).toEqual([8]); + expect(splitInteger(25, 1)).toEqual([25]); }); test('should sort parts ascending if they are not equal', () => { + const result = splitInteger(17, 4); + const sorted = [...result].sort((a, b) => a - b); + expect(result).toEqual(sorted); }); test('should add zeros if value < numberOfParts', () => { - + expect(splitInteger(3, 5)).toEqual([0, 0, 1, 1, 1]); + expect(splitInteger(1, 3)).toEqual([0, 0, 1]); }); From 0ab31984d4e34447ee33723aa24904debd92fceb Mon Sep 17 00:00:00 2001 From: Ihor Haidai Date: Mon, 26 Jan 2026 18:15:38 -0500 Subject: [PATCH 2/2] Final solution --- src/splitInteger.test.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index f6aeaaff..4b5ef80e 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -11,17 +11,13 @@ test(`should split a number into equal parts test(`should return a part equals to a value when splitting into 1 part`, () => { expect(splitInteger(8, 1)).toEqual([8]); - expect(splitInteger(25, 1)).toEqual([25]); }); test('should sort parts ascending if they are not equal', () => { - const result = splitInteger(17, 4); - const sorted = [...result].sort((a, b) => a - b); - - expect(result).toEqual(sorted); + expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]); + expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]); }); test('should add zeros if value < numberOfParts', () => { expect(splitInteger(3, 5)).toEqual([0, 0, 1, 1, 1]); - expect(splitInteger(1, 3)).toEqual([0, 0, 1]); });