Skip to content

Commit f8f1082

Browse files
luismunoz83luismunoz83
authored andcommitted
Iteration ironhack-labs#3: Calculate the sum commit
1 parent d6aeb1b commit f8f1082

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/functions-and-arrays.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ console.log(findLongestWord(words))
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() {
37+
let sum = 0
38+
39+
for (let i = 0; i < numbers.length; i++) {
40+
41+
sum += numbers[i]
42+
43+
}
44+
45+
return sum
46+
}
3747

48+
console.log(sumNumbers(numbers))
3849

3950

4051
// Iteration #3.1 Bonus:

0 commit comments

Comments
 (0)