This function is to calculate averages. It displays NaN on the console and not the actual average. Please guys any help?

const scores = [20, 30, 70, 80, 90]

function calculateAverage(scores){

let sum = 0;
for(let score of scores)
  sum += score;
return sum / scores.lenght; 



I see a typo here. Should be length.
Fix that and tell us if it works.

1 Like

Hello thanks very much I appreciate. It’s crazy how little oversights like this make the difference.

1 Like

No problem.
It happened to me too yet I thought I did reread the code several times.