average
average
计算数组中的平均值
🍱 参数
array
- numbers
🔥 返回值
number
- 平均值
🚀 示例
import { average } from 'atools-js';
average([1, 2, 3, 4, 5]); // 3
💡 源码
source code
/atools/_calc/average.ts
export const average = (numbers: number[]): number => {
return numbers.reduce((acc, curr) => acc + curr, 0) / numbers.length;
};