AlfatArdiansa

Codewars w Sandhika 5

Oct 24th, 2020
638
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function positiveSum(arr) {
  2.   return arr.reduce((a, b) => a + (b > 0 ? b : 0), 0);
  3. }
  4.  
  5. console.log(positiveSum([1, 2, 3, 4, 5]), 15);
  6. console.log(positiveSum([1, -2, 3, 4, 5]), 13);
  7. console.log(positiveSum([]), 0);
  8. console.log(positiveSum([-1, -2, -3, -4, -5]), 0);
  9. console.log(positiveSum([-1, 2, 3, 4, -5]), 9);
  10.  
RAW Paste Data