Skip to content

Commit 60b2996

Browse files
committed
done Array of numbers
1 parent 76640bc commit 60b2996

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/functions-and-arrays.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ function sum(anytype) {
7575
// Level 1: Array of numbers
7676
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];
7777

78-
function averageNumbers() {}
78+
function averageNumbers(array) {
79+
if(array.length === 0){
80+
return null
81+
}
82+
let sum = 0
83+
for (let i = 0; i < array.length; i++) {
84+
sum += array[i]
85+
}
86+
let average = sum / array.length
87+
return average
88+
}
7989

8090

8191
// Level 2: Array of strings

0 commit comments

Comments
 (0)