Skip to content

Commit eae2e83

Browse files
committed
ironhack-labs#3 completed
1 parent 19a3721 commit eae2e83

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/functions-and-arrays.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// } else {
88
// return num2;
99
// }
10-
// }
10+
// };
1111

1212
// ES6
1313
const maxOfTwoNumbers = (num1, num2) => {
@@ -20,16 +20,33 @@ const maxOfTwoNumbers = (num1, num2) => {
2020

2121

2222
// Iteration #2: Find longest word
23-
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
23+
// const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
24+
25+
// const findLongestWord = (a, b) => {
26+
27+
// }
28+
2429

2530
// Iteration #3: Calculate the sum
2631

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

34+
function sumNumbers(numbers){
35+
let sum = 0; // sum starts at 0
36+
for(let i = 0; i < numbers.length; i++) { // loop over array
37+
sum += numbers[i]; // add every number of array to sum
38+
}
39+
return sum; // when iteration of loop is done, return total of sum
40+
}
41+
2942
// Iteration #4: Calculate the average
3043
// Level 1: Array of numbers
3144
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];
3245

46+
function averageNumbers(numbersAvg){
47+
48+
};
49+
3350
// Level 2: Array of strings
3451
const wordsArr = ['seat', 'correspond', 'linen', 'motif', 'hole', 'smell', 'smart', 'chaos', 'fuel', 'palace'];
3552

0 commit comments

Comments
 (0)