I have to print every year that January 1 falls on Sunday from the current year to 2080. How could it be done?
Example: In these years on January 1 is Sunday: 2020,2025,2030 ...
I have to print every year that January 1 falls on Sunday from the current year to 2080. How could it be done?
Example: In these years on January 1 is Sunday: 2020,2025,2030 ...
Easy.
for (i=2018; i <= 2080; i++) {
var date = new Date('1/1/'+i);
if(date.getDay() == 0) console.log(i);
}