Then I need a function that gets the average high. Here is what i did:
function getAverageHeight() {
let total_height = 0;
let average_height = statues.length;
if (statues.length > 0) {
for (let i = 0; i < statues.length; i++) {
let statue = statues[i];
total_height += isNaN(statues.height) ? 0 : statue.height;
}
average_height = (total_height / statues.length).toFixed(2);
}
return average_height;
}
But when i test it i got NaN as as response not the average. What I did wrong here? Can someone give a clue?