entonces quiero obtener el mes actual y los próximos 12 meses en vanilla js. Por ejemplo, al escribir esta pregunta es abril de 2022, así que quiero tener este resultado:
Abril 2022 Mayo 2022 Junio 2022 Julio 2022 Agosto 2022 Septiembre 2022 Octubre 2022 Noviembre 2022 Diciembre 2022 Enero 2023 Febrero 2023 Marzo 2023 Abril 2023
for (let i = 0; i < 13; i++) { let month = new Date().getMonth() + 1 + i; let year = new Date().getFullYear(); if (month > 12) { month = month - 12; year = year + 1; } const nameMonth = { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec", }; console.log(year + " Year " + nameMonth[month] + " Month "); }for (let i = 0; i < 13; i++) { let month = new Date().getMonth() + 1 + i; let year = new Date().getFullYear(); if (month > 12) { month = month - 12; year = year + 1; } const nameMonth = { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec", }; console.log( year + " Year " + nameMonth[month] + " Month " ); }