+ 14
[CHALLENGE] sum positive count negative
Make a function that calculates sum of positive numbers and counts negative numbers. Given array = [1,2,3,4,5,-1,-2,-3,-4,-5] Output: sum of positive numbers = 15 count of negative numbers = 5
7 Respostas
+ 14
you can now submit challenges in the lesson factory
just choose "assignment" and submit your challenge
and also
var arr = [1,2,3,4,5,-1,-2,-3,-4,-5];
alert(arr.filter(function(v){ return v > 0;}).reduce(function(a, b){return a + b;}));
alert(arr.filter(function(v){ return v < 0;}).length);
+ 9
@Burey I submitted all of my challenges in lesson factory.
Btw nice inlines.
+ 2
The most basic solution in js:
https://code.sololearn.com/W8s0WcT036To/#js