From 0b2b8019c2e09ab4b102bb09366da8a042d12893 Mon Sep 17 00:00:00 2001 From: VSkits Date: Mon, 30 Jun 2025 12:48:28 +0300 Subject: [PATCH 1/2] solution --- src/splitInteger.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index a610317d..3c0c081e 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -4,18 +4,18 @@ const splitInteger = require('./splitInteger'); test(`should split a number into equal parts if a value is divisible by a numberOfParts`, () => { - + expect(splitInteger(8, 2)).toEqual([4, 4]); }); test(`should return a part equals to a value when splitting into 1 part`, () => { - + expect(splitInteger(1000, 1)).toHaveLength(1); }); test('should sort parts ascending if they are not equal', () => { - + expect(splitInteger(10, 3)).toEqual([3, 3, 4]); }); test('should add zeros if value < numberOfParts', () => { - + expect(splitInteger(4, 5)).toContain(0); }); From c0c7f6765436973a4bfdceb761a44a8376aeaa97 Mon Sep 17 00:00:00 2001 From: VSkits Date: Mon, 30 Jun 2025 14:02:52 +0300 Subject: [PATCH 2/2] add implementation --- src/splitInteger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/splitInteger.js b/src/splitInteger.js index d3da7485..1b6eabe7 100644 --- a/src/splitInteger.js +++ b/src/splitInteger.js @@ -17,7 +17,7 @@ function splitInteger(value, numberOfParts) { rest -= part; } - return parts; + return parts.sort((a, b) => a - b); } module.exports = splitInteger;