var arr = [];
var arr2 = [];
var results = [];
for (var i = 1; i <= 30; i++) {
arr.push(i * 2);
arr2.push(i * 2);
if (i % 5 == 0) {
results.push(average(arr));
arr = [];
}
}
function average(arr) {
var sum = 0;
for (var i = 0; i < arr.length; i++) {
sum += arr[i]
}
return sum / arr.length
}
console.log(arr2)
console.log(results)