Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

average of an array js

const avg = arr => {
  const sum = arr.reduce((acc, cur) => acc + cur);
  const average = sum/arr.length;
  return average;
}

console.log(avg([1, 2, 3, 7, 8]));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #average #array #js
ADD COMMENT
Topic
Name
8+5 =