Skip to content

Commit c7b2ce6

Browse files
committed
Done Iteration Calculate the Sum
1 parent 3d56ce4 commit c7b2ce6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/functions-and-arrays.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ function findLongestWord(array) {
3333
// Iteration #3: Calculate the sum
3434
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
3535

36-
function sumNumbers() {}
36+
function sumNumbers(arrayNumbers) {
37+
if(arrayNumbers.length === 0){
38+
return 0
39+
}
40+
let sum = 0
41+
for (let i = 0; i < arrayNumbers.length; i++) {
42+
sum += arrayNumbers[i]
43+
}
44+
return sum
45+
}
3746

3847

3948

0 commit comments

Comments
 (0)