At the moment it always takes the same 72 elements. How can I manage that after each round it takes the next 72 values e.g. 73 - 144 than 145 - 217 etc.?
var houseconsumtion_week = new Array();
var i = 0;
var sum = 0;
// should loop 28 times, houseconsumtion.length = Array containing 2016 elements
for (var j = 0; j < houseconsumtion.length; j+=72) {
for (var i = 0; i < 72; i++) {
sum += houseconsumtion[i];
}
houseconsumtion_week.push(sum);
}
You can access the element at index i + j each time.
for (var j = 0; j < houseconsumtion.length; j += 72) {
for (var i = 0; i < 72; i++) {
sum += houseconsumtion[i + j];
}
houseconsumtion_week.push(sum);
}