Average number from array using .reduce() help please

I want my code to reduce the array to one number, which will be arithmetic average of all numbers in the array. I have written the code bellow but it’s not working. It sums first two numbers in the array, but then it doesnt and returns NaN. :frowning: Can anyone help?

var pushed = [8.8,8.6,9,8.3];

var test;

var sum = 0;

var avg = 0;

test = pushed.reduce(function(a, b) {  
  sum =  a + b;  
  console.log(sum);
  avg = sum / pushed.length;
  console.log(avg);  
})

let pushed = [8.8, 8.6, 9, 8.3];
pushed.reduce( ( a0, a1) => a0 + a1/ pushed.length ,0);

i solved it another way

 test = pushed.reduce(function(a, b) {  
  return a + b / pushed.length;
}, 0)

the thing is i didnt set initial value

great. It’s still not fast enough.