I'm trying to make a function where there is a for loop so I can get the average of the numbers inside an array and found this solution to adding them in stack overflow, which contains the line
z += array[i];
The thing is i don't know what it does, can anybody explain?
var x = [80, 82, 84, 92];
function PromedioArrays(array) {
var z = 0;
for (var i = 0; i < array.length; i++) {
z += array[i];
console.log(array[i]);
console.log(z);
}
console.log(z / array.length);
}
PromedioArrays(x);