Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function countPositivesSumNegatives(input) {

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('count of positives and sum of negatives', function() {

it('should count positive numbers and sum negative numbers', function() {
expect(countPositivesSumNegatives([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15])).toEqual([10, -65]);
expect(countPositivesSumNegatives([0, 2, 3, 0, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14])).toEqual([8, -50]);
});

it('should return an empty array when input array is empty or null', function() {
expect(countPositivesSumNegatives([])).toEqual([]);
expect(countPositivesSumNegatives(null)).toEqual([]);
});
});
16 changes: 16 additions & 0 deletions katas/count-of-positives-sum-of-negatives/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
####Description:

Implement a function that takes an array of integers and returns an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.
If the input array is empty or null, return an empty array.

####Example:

```js
countPositivesSumNegatives([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]) => [10, -65]
```

See [tests in count-of-positives-sum-of-negatives_test.js](https://github.com/AlexVvx/code-wars/blob/master/katas/count-of-positives-sum-of-negatives_test/count-of-positives-sum-of-negatives_test.js)

Good luck

#####[Original Kata](https://www.codewars.com/kata/count-of-positives-slash-sum-of-negatives)