Hey there, I'm struggling with a class assignment that involves finding the average of an array of even numbers that we're supposed to generate. Unfortunately, I can't seem to get it working properly.
var arrayOfNumbers = [];
for (var num = 1; num <= 100; num++) {
if (num % 2 == 0) {
arrayOfNumbers.push(num);
}
}
var sum = 0;
for (var index in arrayOfNumbers) {
sum += arrayOfNumbers[index];
sum / 50;
}
document.write(sum);
I've included the code above - could you please point out what I might be doing wrong? It seems like the array isn't populating with even numbers as expected. Any assistance would be greatly appreciated since my professor doesn't respond to emails quickly.
Thank you!