diff --git a/katas/count-of-positives-sum-of-negatives/count-of-positives-sum-of-negatives.js b/katas/count-of-positives-sum-of-negatives/count-of-positives-sum-of-negatives.js new file mode 100644 index 0000000..84ccce5 --- /dev/null +++ b/katas/count-of-positives-sum-of-negatives/count-of-positives-sum-of-negatives.js @@ -0,0 +1,3 @@ +function countPositivesSumNegatives(input) { + +}; \ No newline at end of file diff --git a/katas/count-of-positives-sum-of-negatives/count-of-positives-sum-of-negatives_test.js b/katas/count-of-positives-sum-of-negatives/count-of-positives-sum-of-negatives_test.js new file mode 100644 index 0000000..d7127b1 --- /dev/null +++ b/katas/count-of-positives-sum-of-negatives/count-of-positives-sum-of-negatives_test.js @@ -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([]); + }); +}); diff --git a/katas/count-of-positives-sum-of-negatives/readme.md b/katas/count-of-positives-sum-of-negatives/readme.md new file mode 100644 index 0000000..59cdbdc --- /dev/null +++ b/katas/count-of-positives-sum-of-negatives/readme.md @@ -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) \ No newline at end of file