Skip to content

Commit bebf199

Browse files
66 solution one added
1 parent 8f87224 commit bebf199

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

problem66/problme66.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,20 @@
33
44
Example Input: [2, -5, 10, -3, 7] Example Output: 19 */
55

6+
/* ----------------------------------
7+
Solution One using for loop:
8+
------------------------------------- */
9+
10+
function calculatePositiveNumbers(arrayOfNumbers){
11+
12+
let total = 0;
13+
for( let i = 0; i < arrayOfNumbers.length; i++){
14+
if(arrayOfNumbers[i] > 0){
15+
total = total + arrayOfNumbers[i];
16+
}
17+
}
18+
19+
return total;
20+
};
21+
22+
console.log(calculatePositiveNumbers([2, -5, 10, -3, 7]));

0 commit comments

Comments
 (0)