Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /