📜  javascript 数组中数字的平均值 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:30.608000             🧑  作者: Mango

代码示例3
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]));