Skip to content

Commit 022d791

Browse files
committed
add solution ironhack-labs#4.1
1 parent 31ed2a8 commit 022d791

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/functions-and-arrays.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ function sum(input) {
6060
// Level 1: Array of numbers
6161
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];
6262

63-
function averageNumbers() {}
63+
function averageNumbers(input) {
64+
if (!input || input.length === 0) {
65+
return null;
66+
}
67+
let sumElements = sum(input);
68+
return sumElements/input.length;
69+
}
6470

6571
// Level 2: Array of strings
6672
const wordsArr = ['seat', 'correspond', 'linen', 'motif', 'hole', 'smell', 'smart', 'chaos', 'fuel', 'palace'];

0 commit comments

Comments
 (0)