Skip to content

Commit

Permalink
Commit 10 - Longest Word
Browse files Browse the repository at this point in the history
  • Loading branch information
annadruzhinina committed Nov 18, 2022
1 parent 63b77ee commit 17e530d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 17e530d

Please sign in to comment.