Sum of positive from an array of numbers
The array also includes negative numbers.
This is an exercise from CodeWars.
You get an array of numbers, return the sum of all of the positives ones.
1 + 7 + 12 = 20
Note: if there is nothing to sum, the sum is default to
Here’s my simple solution using Linq.
public class Kata
public static int PositiveSum(int arr)
return arr.Where(x => x > 0).Sum();