Looking to receive an array and take and return the average. If it is an empty string return 0. This is the code I have so far.
For some reason I am getting NaN when entered an empty array.
function calculateAverage(numbers) {
if ((numbers = [])) return 0;
let total = 0;
for (let num of numbers) {
total += num;
}
let result = total / numbers.length;
return result;
}