JavaScript
const avg = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length
Examples
avg(...[1, 2, 3]) // 2
avg(1, 2, 3) // 2
标签:acc,...,平均值,多个,nums,val,avg,数字
From: https://www.cnblogs.com/sunr/p/js_array_avg.html
const avg = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length
avg(...[1, 2, 3]) // 2
avg(1, 2, 3) // 2
标签:acc,...,平均值,多个,nums,val,avg,数字
From: https://www.cnblogs.com/sunr/p/js_array_avg.html