Hello we have a problem in class to get the average out of a array of even numbers that we generate and I can't seem to get it to work.
var theArray = [];
for (var i = 1; i <= 100; i++) {
if (i % 2 == 0) {
theArray.push(i);
}
}
var total1 = 0;
for (var element in theArray) {
total1 += theArray[element];
total1 / 50;
}
document.write(total1);
This is the code, what am I doing wrong as I don't the array is even filling up. Any help will be great as the professor doesn't answer email very fast.
Thanks!