Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/splitInteger.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
return parts;
}

console.log(splitInteger());

Check failure on line 23 in src/splitInteger.js

View workflow job for this annotation

GitHub Actions / build (12.x)

Unexpected console statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: The function splitInteger is called without any arguments. According to the function definition, it requires two arguments: value and numberOfParts. This will cause incorrect behavior or errors. Please provide appropriate arguments when calling the function.


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Related to the previous line: ensure that you test the function with valid arguments, such as splitInteger(10, 3).

module.exports = splitInteger;
10 changes: 10 additions & 0 deletions src/splitInteger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ const splitInteger = require('./splitInteger');
test(`should split a number into equal parts
if a value is divisible by a numberOfParts`, () => {

const result = splitInteger(8, 2);

expect(result).toEqual([4, 4]);
});

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

const result = splitInteger(8, 1);

expect(result).toEqual([8]);
});

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

expect(result).toEqual([2, 3, 3]);
});

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

expect(result).toEqual([0, 0, 1]);
});
Loading