Skip to content

Commit 5e3ff24

Browse files
Merge pull request #13 from Ameer67/find-average
Added function to calculate average
2 parents 40bc4c1 + 4ac601c commit 5e3ff24

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

JSAlgorithms/findAverage.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function findAverage(array) {
2+
let runningTotal = 0;
3+
for (i = 0; i < test.length; i++) {
4+
runningTotal += array[i];
5+
}
6+
return runningTotal / array.length;
7+
}
8+
9+
let test = [3, -1, 0, 9];
10+
console.log(findAverage(test));

0 commit comments

Comments
 (0)