Help please derive the arithmetic average of the array, with the help of a function that takes an array. My function is NaN !!! Why?
class Car{ constructor(prise){ this.prise = prise; } }; function averageСost(arr) { var total = 0; for(var i = 0; i < arr.length; i++) { total = (total + arr[i]) / arr.length;; } return total; } ; var car1 = new Car(10000); var car2 = new Car(20000); var car3 = new Car (30000); var cars = [car1,car2,car3]; console.log(averageСost(cars));