Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Average of an array #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/findaverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
input :[1,2,3]
output:6
*/

export const arrayAverage = (array) => {
let sum = 0;
let len = array.length;
array.forEach( i => {
sum += array[i];
});

return sum/len;
};