js reduce calculate average code example
Example: reduce average javascript
function average(nums) {
// nums.length is the important part
return nums.reduce((a, b) => (a + b)) / nums.length;
}
function average(nums) {
// nums.length is the important part
return nums.reduce((a, b) => (a + b)) / nums.length;
}