I have a function that identifies the month by means of two entries, the initial month and also the difference that would be the maximum range of my array. At the same time there is another condition that in this case limits my list to 6 values
var CountMes = 0;
function DataTabela(mesInicial, Diferenca) {
var Meses = [];
Meses.push(mesInicial);
while (CountMes < 5 && Diferenca > CountMes) {
CountMes++;
mesInicial++;
Meses.push(mesInicial);
}
alert(Meses.toString());
}
It works perfectly while we are in the same year. My problem is, if my initial month entry is 11 (November) and my difference is 4, my list should have: November, December, January, and February. But since the account is base 12 and January would be equivalent to mesInicial = 1
, how can I model my function so that it is adaptable for year transitions?