Skip to content

Commit f479e91

Browse files
add task solution
1 parent 3fd8d93 commit f479e91

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/splitInteger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ function splitInteger(value, numberOfParts) {
2020
return parts;
2121
}
2222

23+
console.log(splitInteger());
24+
2325
module.exports = splitInteger;

src/splitInteger.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,27 @@ const splitInteger = require('./splitInteger');
55
test(`should split a number into equal parts
66
if a value is divisible by a numberOfParts`, () => {
77

8+
const result = splitInteger(8, 2);
9+
10+
expect(result).toEqual([4, 4]);
811
});
912

1013
test(`should return a part equals to a value
1114
when splitting into 1 part`, () => {
1215

16+
const result = splitInteger(8, 1);
17+
18+
expect(result).toEqual([8]);
1319
});
1420

1521
test('should sort parts ascending if they are not equal', () => {
22+
const result = splitInteger(8, 3);
1623

24+
expect(result).toEqual([2, 3, 3]);
1725
});
1826

1927
test('should add zeros if value < numberOfParts', () => {
28+
const result = splitInteger(1, 3);
2029

30+
expect(result).toEqual([0, 0, 1]);
2131
});

0 commit comments

Comments
 (0)