Skip to content

Commit ef282d0

Browse files
committed
Iteration ironhack-labs#3: Calculate the sum
1 parent bd0c40a commit ef282d0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/functions-and-arrays.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function maxOfTwoNumbers(a, b) {
1111
// Iteration #2: Find longest word
1212
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
1313

14-
1514
function findLongestWord(list1) {
1615
let lenList = list1.length;
1716
let longestWord = "";
@@ -31,6 +30,14 @@ function findLongestWord(list1) {
3130

3231
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
3332

33+
function sumNumbers(numbersList1) {
34+
let sum = "";
35+
for (let i = 0, sum = 0; i < numbersList1.length; i++){
36+
newSum = sum += numbersList1[i++]
37+
}
38+
return newSum;
39+
}
40+
3441
// Iteration #4: Calculate the average
3542
// Level 1: Array of numbers
3643
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];

0 commit comments

Comments
 (0)