From 6c814e939dcca6fd6a9cc9deac79bf84eb4b7200 Mon Sep 17 00:00:00 2001 From: Corinne GoodSmith Date: Wed, 4 Sep 2024 14:18:31 -0500 Subject: [PATCH] added daily codewars challenge --- codewars.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/codewars.js b/codewars.js index d3ea6a0..798b0c9 100644 --- a/codewars.js +++ b/codewars.js @@ -68,4 +68,10 @@ let sumMix = (x) => x.map((num) => +num).reduce((sum,acc)=>sum+acc,0) //Function 2 - squaring an argument -let square = (num)=>num**2 \ No newline at end of file +let square = (num)=>num**2 + +//Sum of positive +//Only add the positive numbers of an array together +function positiveSum2(arr) { + return arr.filter((num) => num > 0).reduce((sum, current)=> sum + current, 0) +} \ No newline at end of file