Hello everyone, I'm trying to fill an array with days from the current day until 30 days from now.
Here's a problem: if today is day 8, in 30 days it will be 38, but I want the count to go back to 1 from the maximum day of each month. To work around this, I'm trying to use the following logic:
//busca o dia de hoje e preenche o array com os dias de hoje + 30 dias
var today = new Date();
var dd = today.getDate();
var somaTrinta = dd + 30;
//vetor que possui o máximo de dias por cada mês
var diasPorMes = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var mm = today.getMonth();
var maximoDias = diasPorMes[mm];
var i;
for(i = dd; i < somaTrinta; i++) {
if (i > maximoDias) {
i = 1;
}
horizontal.push(i);
}
However, after inserting the if, the page no longer loads. I do not know what my mistake is, can someone help me? Thanks