Answers for "mean of a javascript array"

CSS
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

Browse Popular Code Answers by Language