Skip to content

Commit 9f96558

Browse files
Merge pull request #14 from gSchool/feature-average-stats
Adds stat calculation for list average
2 parents 724925d + d61d663 commit 9f96558

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { average } from "./stats.js";
1+
import { averageOfList } from "./stats.js";
22

33
const data = [24, 987, 23, 973, 32, 3462, 382, 53];
44

stats.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
// Define a function called average which returns the average of a list of numbers.
22
// Define a function called median which returns the median of an array of numbers.
33
// Define a function called standardDev which returns the standard deviation of an array of numbers.
4+
5+
export const averageOfList = (arr) => {
6+
return arr.reduce((a, b) => a + b, 0) / arr.length;
7+
}

0 commit comments

Comments
 (0)