From 17e530d113257fac7996c7ae852a9ec565e05e54 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 17 Nov 2022 22:39:20 -0500 Subject: [PATCH] Commit 10 - Longest Word --- app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app.js b/app.js index 4698fef..1d851a1 100644 --- a/app.js +++ b/app.js @@ -167,7 +167,15 @@ findNeedle(["hay", "junk", "hay", "hay", "moreJunk", "needle", "randomJunk"]); // 10. sumPositive function sumPositive(arr) { // YOUR CODE HERE + let sum = 0; + for (let i = 0; i < arr.length; i++) { + if (arr[i] > 0) { + sum += arr[i]; + } + } + return sum; } +console.log(sumPositive([1, -4, 7, 12])); module.exports = { calculateCube,