Answers for "how to find average in an array javascript"

CSS
8

how to calculate average of array in javascript

const arrAvg = arr => arr.reduce((a,b) => a + b, 0) / arr.length
Posted by: Guest on March-23-2020
2

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]));
Posted by: Guest on February-29-2020

Code answers related to "how to find average in an array javascript"

Browse Popular Code Answers by Language