Answers for "js finding average of an array using .reduce with example"

3

reduce average javascript

function average(nums) {
  	// nums.length is the important part
    return nums.reduce((a, b) => (a + b)) / nums.length;
}
Posted by: Guest on December-08-2020
3

javascript average of arguments

const average = (...args) => args.reduce((a, b) => a + b) / args.length;

// Example
average(1, 2, 3, 4);    // 2.5
Posted by: Guest on July-03-2020

Code answers related to "js finding average of an array using .reduce with example"

Code answers related to "Javascript"

Browse Popular Code Answers by Language