how to get an average using reduce javascript 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;
}