Sum of positive codewars javascript
// You get an array of numbers, return the sum of all of the positives ones. // Example [1,-4,7,12] => 1 + 7 + 12 = 20 Permalink Cannot retrieve contributors at this time You get an array of numbers, return the sum of all of the positives ones. Example [1,-4,7,12] => 1 + 7 + 12 = 20 Note: array may be empty, in this case return 0.
Chek kata on Codewars Description:
Solution 1Let's use
There are a few variations of this solution. The main difference is how we check if the number is positive or not. Solution 1.1
Solution 1.2
Solution 1.3
Solution 2For loop will do the trick as well.
Solution 2.1Or forEach loop also works fine.
Sum of positive
Description:Loading description... Similar Kata:Stats:
|